# HG changeset patch # User Matti Hamalainen # Date 1528969349 -10800 # Node ID 45e7688336dcebbff3aa12ba5090cd6aa4d56c75 # Parent 708d333734f94ea20080bc1aaf4d26bcc6e4a501 Fix checks for NULL palette in index/palette images. Also improve error messages. diff -r 708d333734f9 -r 45e7688336dc tools/libgfx.c --- a/tools/libgfx.c Thu Jun 14 12:41:55 2018 +0300 +++ b/tools/libgfx.c Thu Jun 14 12:42:29 2018 +0300 @@ -951,7 +951,16 @@ // XXX: 24bit PCX does not work yet .. if (!spec.paletted) - return DMERR_NOT_SUPPORTED; + { + return dmError(DMERR_NOT_SUPPORTED, + "24bit PCX not supported yet.\n"); + } + + if (spec.paletted && img->pal == NULL) + { + return dmError(DMERR_NULLPTR, + "Image spec says paletted/indexed image, but palette pointer is NULL.\n"); + } // Create output file pcx.buf = NULL; @@ -960,7 +969,7 @@ // Create PCX header dmMemset(&hdr, 0, sizeof(hdr)); - if (spec.paletted && img->pal != NULL) + if (spec.paletted) { for (int i = 0; i < (img->ncolors > DMPCX_PAL_COLORS ? DMPCX_PAL_COLORS : img->ncolors); i++) {