changeset 1460:361cad3b8445

Improve error handling.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 10 May 2018 21:19:55 +0300
parents 1155f4bc4afc
children 96c254579b82
files tools/lib64gfx.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)