[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Query on kdelibs/kdecore/io/kgrantpty.c
From: "Boyd Stephen Smith Jr." <bss03 () volumehost ! net>
Date: 2007-07-29 7:38:26
Message-ID: 200707290238.31737.bss03 () volumehost ! net
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
On Sunday 29 July 2007 02:15:54 am Brad Hards wrote:
> I'm doing some experiments with a static checker, and my initial rule
> checks threw up a lot of errors, possibly many false alarms [dear lazyweb,
> is it an error to do FooClass *p = new FooClass; p->member = bar; without
> checking if p is null?]
Depends. Standard C++ says new doesn't return NULL, 0, or any other null
pointer; it throws an instance of std::bad_alloc instead. I forget how to
make new return a null pointer (which may or may not *be* NULL, but will
compare equal to NULL).
> One that does look like an error is in kgrantpty.c
> Around line 149 is this line:
> tty = malloc(strlen(pty) + 1);
>
> That never gets free()'d that I can see.
>
> Does that count as a bug, or is it OK because this is a standalone
> application and it gets cleaned up on exit?
It's a bug, in that application. A non-buggy OS will clean up where the
application doesn't though, so if the application isn't meant to be
long-running it shouldn't cause many problems. (It's still a bug though.)
I'd imagine that code could be fairly easily replaced with some QString or
QByteArray code.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss03@volumehost.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.org/ \_/
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic