libansilove

Library for converting ANSI, ASCII, and other formats to PNG
Log | Files | Refs | README | LICENSE

commit c1b0ca7e32ca88d58964044beade824381bdcf42
parent 02527f85788b3bfd37ed591d82facc549be1935f
Author: Frederic Cambus <fred@statdns.com>
Date:   Wed, 24 Oct 2018 18:53:57 +0200

Return an error if gdImageCreate() or gdImageCreateTrueColor() fail

Diffstat:
Msrc/output.c | 10++++++++++
1 file changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/output.c b/src/output.c @@ -25,6 +25,11 @@ int output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImagePt im_DOS = gdImageCreateTrueColor(im_Source->sx, im_Source->sy * 1.35); + if (!im_DOS) { + ctx->error = ANSILOVE_GD_ERROR; + return -1; + } + gdImageCopyResampled(im_DOS, im_Source, 0, 0, 0, 0, im_DOS->sx, im_DOS->sy, im_Source->sx, im_Source->sy); @@ -38,6 +43,11 @@ int output(struct ansilove_ctx *ctx, struct ansilove_options *options, gdImagePt im_Retina = gdImageCreate(im_Source->sx * options->retinaScaleFactor, im_Source->sy * options->retinaScaleFactor); + if (!im_Retina) { + ctx->error = ANSILOVE_GD_ERROR; + return -1; + } + gdImageCopyResized(im_Retina, im_Source, 0, 0, 0, 0, im_Retina->sx, im_Retina->sy, im_Source->sx, im_Source->sy);