Fix bug reported by static analyser - NSData was testing ivars instead of arguments in -initWithBytesNoCopy:length:freeWhenDone:. The correct behaviour was to throw an exception if passed a NULL pointer and a length. The actual behaviour was to test whether the data object was invalid. This could lead to accidental NULL-pointer dereferencing later.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32030 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Chisnall 2011-02-10 10:13:50 +00:00
parent 021d3680d7
commit 2edfea16be

View file

@ -2526,7 +2526,7 @@ failure:
length: (NSUInteger)bufferSize
freeWhenDone: (BOOL)shouldFree
{
if (bytes == 0 && length > 0)
if (aBuffer == 0 && bufferSize > 0)
{
[NSException raise: NSInvalidArgumentException
format: @"[%@-initWithBytesNoCopy:length:freeWhenDone:] called with "