changeset 1548:20cd589366d7

Check C64 bitmap format flags in encode/decode functions.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 12 May 2018 21:05:52 +0300
parents fa4fa9a6e78f
children 87af4e63a392
files tools/lib64gfx.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Sat May 12 21:02:42 2018 +0300
+++ b/tools/lib64gfx.c	Sat May 12 21:05:52 2018 +0300
@@ -1023,7 +1023,10 @@
         return DMERR_INVALID_ARGS;
 
     if (*fmt == NULL)
-        return DMERR_INVALID_DATA;
+        return DMERR_NOT_SUPPORTED;
+
+    if (((*fmt)->flags & DM_FMT_RD) == 0)
+        return DMERR_NOT_SUPPORTED;
 
     // Allocate memory
     if ((*img = dmC64ImageAlloc(*fmt)) == NULL)
@@ -1076,6 +1079,9 @@
     if (img == NULL || fmt == NULL)
         return DMERR_NULLPTR;
 
+    if ((fmt->flags & DM_FMT_WR) == 0)
+        return DMERR_NOT_SUPPORTED;
+
     // Allocate a buffer
     if ((res = dmGrowBufAlloc(buf, BUF_SIZE_INITIAL, BUF_SIZE_GROW)) != DMERR_OK)
         goto err;