Skip to content

Commit

Permalink
Backgrounds: FlattenedSize() can be negative (error status)
Browse files Browse the repository at this point in the history
CID 610928.
  • Loading branch information
stpere committed Jul 2, 2015
1 parent 24b1f93 commit 02ab820
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/preferences/backgrounds/BackgroundImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,10 @@ BackgroundImage::SetBackgroundImage(BNode* node)

PRINT_OBJECT(container);

size_t flattenedSize = container.FlattenedSize();
ssize_t flattenedSize = container.FlattenedSize();
if (flattenedSize < B_OK)
return flattenedSize;

char* buffer = new(std::nothrow) char[flattenedSize];
if (buffer == NULL)
return B_NO_MEMORY;
Expand All @@ -511,7 +514,7 @@ BackgroundImage::SetBackgroundImage(BNode* node)

if (size < B_OK)
return size;
if ((size_t)size != flattenedSize)
if (size != flattenedSize)
return B_ERROR;

return B_OK;
Expand Down

0 comments on commit 02ab820

Please sign in to comment.