Browse Source

free data if src malloc() fails

v1.x
Tj Holowaychuk 14 years ago
parent
commit
52e24d893f
  1. 5
      src/Image.cc

5
src/Image.cc

@ -305,7 +305,10 @@ Image::loadJPEG() {
if (!data) return ThrowException(Canvas::Error(CAIRO_STATUS_NO_MEMORY)); if (!data) return ThrowException(Canvas::Error(CAIRO_STATUS_NO_MEMORY));
uint8_t *src = (uint8_t *) malloc(width * 3); uint8_t *src = (uint8_t *) malloc(width * 3);
if (!src) return ThrowException(Canvas::Error(CAIRO_STATUS_NO_MEMORY)); if (!src) {
free(data);
return ThrowException(Canvas::Error(CAIRO_STATUS_NO_MEMORY));
}
// Copy RGB -> ARGB // Copy RGB -> ARGB
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {

Loading…
Cancel
Save