# HG changeset patch # User Matti Hamalainen # Date 1525976395 -10800 # Node ID 361cad3b8445da34f2c0734fa8dd2ca6c6b7ae98 # Parent 1155f4bc4afc8fb74c2f68910319564b0b52ca02 Improve error handling. diff -r 1155f4bc4afc -r 361cad3b8445 tools/lib64gfx.c --- a/tools/lib64gfx.c Thu May 10 21:16:43 2018 +0300 +++ b/tools/lib64gfx.c Thu May 10 21:19:55 2018 +0300 @@ -1114,6 +1114,8 @@ int dmC64DecodeGenericBMP(DMC64Image *img, const Uint8 *buf, const size_t len, const DMC64ImageFormat *fmt) { + int res = DMERR_OK; + if (buf == NULL || img == NULL || fmt == NULL) return DMERR_NULLPTR; @@ -1131,7 +1133,6 @@ const DMC64EncDecOp *op = &fmt->encdecOps[i]; const Uint8 *src; size_t size; - int res; // Check for last operator if (op->type == DT_LAST) @@ -1423,7 +1424,11 @@ return DMERR_NULLPTR; if (dst->width < src->width || dst->height < src->height) - return DMERR_INVALID_DATA; + { + return dmError(DMERR_INVALID_DATA, + "Invalid src vs. dst width/height %d x %d <-> %d x %d\n", + src->width, src->height, dst->width, dst->height); + } dmMemset(dst->data, 0, dst->size); @@ -1585,10 +1590,10 @@ { // Nope, perform a generic probe if (probeOffs >= len) - return DMERR_INVALID_DATA; + return DMERR_OUT_OF_DATA; if (dmC64ProbeBMP(buf + probeOffs, len - probeOffs, fmt) == DM_PROBE_SCORE_FALSE) - return DMERR_INVALID_DATA; + return DMERR_NOT_SUPPORTED; } if (loadOffs >= len)