Commits

tabe  committed 4b5a9f8

fixed possible segfaults when gdNewDynamicCtx() returns null

  • Participants
  • Parent commits 46290a4
  • Branches GD-2.0

Comments (0)

Files changed (9)

File src/gd_bmp.c

 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageBmpCtx(im, out, compression);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);
 {
 	gdImagePtr im;
 	gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0);
+	if (in == NULL) return NULL;
 	im = gdImageCreateFromBmpCtx(in);
 	in->gd_free(in);
 	return im;
 {
   void *rv;
   gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
+  if (out == NULL) return NULL;
   _gdImageGd (im, out);
   rv = gdDPExtractData (out, size);
   out->gd_free (out);

File src/gd_gd2.c

 {
   void *rv;
   gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
+  if (out == NULL) return NULL;
   _gdImageGd2 (im, out, cs, fmt);
   rv = gdDPExtractData (out, size);
   out->gd_free (out);

File src/gd_gif_out.c

 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageGifCtx(im, out);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);
 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);
 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);

File src/gd_jpeg.c

 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageJpegCtx(im, out, quality);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);

File src/gd_png.c

 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
+	if (out == NULL) return NULL;
 	gdImagePngCtxEx (im, out, -1);
 	rv = gdDPExtractData (out, size);
 	out->gd_free (out);
 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
+	if (out == NULL) return NULL;
 	gdImagePngCtxEx (im, out, level);
 	rv = gdDPExtractData (out, size);
 	out->gd_free (out);

File src/gd_tga.c

 {
 	gdImagePtr im;
 	gdIOCtx *in = gdNewDynamicCtxEx (size, data, 0);
+	if (in == NULL) return NULL;
 	im = gdImageCreateFromTgaCtx(in);
 	in->gd_free(in);
 	return im;

File src/gd_tiff.c

 {
 	gdImagePtr im;
 	gdIOCtx *in = gdNewDynamicCtxEx (size, data, 0);
+	if (in == NULL) return NULL;
 	im = gdImageCreateFromTiffCtx(in);
 	in->gd_free(in);
 	return im;
 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx (2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageTiffCtx(im, out); /* what's an fg again? */
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);

File src/gd_wbmp.c

 {
 	void *rv;
 	gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
+	if (out == NULL) return NULL;
 	gdImageWBMPCtx(im, fg, out);
 	rv = gdDPExtractData(out, size);
 	out->gd_free(out);