Skip to content

Commit

Permalink
GIFTranslator: call new(std::nothrow) BBitmap again
Browse files Browse the repository at this point in the history
... to prevent throwing a std::bad_alloc exception if there isn't
enough memory to allocate a new BBitmap.

This effectively reverts 116e78d

Thanks Axel and AnEvilYak and sorry for the noise.
  • Loading branch information
jscipione committed Mar 6, 2014
1 parent 15791c1 commit 7b46114
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/add-ons/translators/gif/GIFTranslator.cpp
Expand Up @@ -167,7 +167,10 @@ GetBitmap(BPositionIO* in, BBitmap** out)
header.dataSize = B_BENDIAN_TO_HOST_INT32(header.dataSize);

// dump data from stream into a BBitmap
*out = new BBitmap(header.bounds, header.colors);
*out = new(std::nothrow) BBitmap(header.bounds, header.colors);
if (*out == NULL)
return B_NO_MEMORY;

if (!(*out)->IsValid()) {
delete *out;
return B_NO_MEMORY;
Expand Down

0 comments on commit 7b46114

Please sign in to comment.