From 7b46114834d5a8bf7d25e662ee22b5a435617ba0 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 5 Mar 2014 17:56:40 -0500 Subject: [PATCH] GIFTranslator: call new(std::nothrow) BBitmap again ... to prevent throwing a std::bad_alloc exception if there isn't enough memory to allocate a new BBitmap. This effectively reverts 116e78d4d4c1f8087a8e70707acc4227c5d0edf7 Thanks Axel and AnEvilYak and sorry for the noise. --- src/add-ons/translators/gif/GIFTranslator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/add-ons/translators/gif/GIFTranslator.cpp b/src/add-ons/translators/gif/GIFTranslator.cpp index 1eb442d8061..9eb639ef1f4 100644 --- a/src/add-ons/translators/gif/GIFTranslator.cpp +++ b/src/add-ons/translators/gif/GIFTranslator.cpp @@ -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;