# HG changeset patch # User Matti Hamalainen # Date 1526148352 -10800 # Node ID 20cd589366d7f997022bef61d06c9a8ff3638bce # Parent fa4fa9a6e78f5f2a94146003ac8e09a7bcafe17c Check C64 bitmap format flags in encode/decode functions. diff -r fa4fa9a6e78f -r 20cd589366d7 tools/lib64gfx.c --- 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;