comparison tools/lib64gfx.c @ 2196:28871f500e84

Add new "flags" field to DMC64EncDecOp, defined by DF_* that can be used to specify additional control over the operator blocks.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 13 Jun 2019 22:07:16 +0300
parents 71880ce885dd
children dcd26cdc395e
comparison
equal deleted inserted replaced
2195:868b68c188e5 2196:28871f500e84
834 } 834 }
835 835
836 836
837 int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img) 837 int dmC64SanityCheckEncDecOp(const int i, const DMC64EncDecOp *op, const DMC64Image *img)
838 { 838 {
839 if (op->flags == 0)
840 {
841 return dmError(DMERR_INTERNAL,
842 "Invalid operation flags value %d in generic encode/decode operator %d @ #%d.\n",
843 op->flags, op->type, i);
844 }
845
839 switch (op->type) 846 switch (op->type)
840 { 847 {
841 case DO_COPY: 848 case DO_COPY:
842 case DO_SET_MEM: 849 case DO_SET_MEM:
843 case DO_SET_MEM_HI: 850 case DO_SET_MEM_HI:
1013 1020
1014 // Check operation validity 1021 // Check operation validity
1015 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK) 1022 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK)
1016 return res; 1023 return res;
1017 1024
1025 // Check flags
1026 if ((op->flags & DF_DECODE) == 0)
1027 continue;
1028
1018 // Is the operation inside the bounds? 1029 // Is the operation inside the bounds?
1019 size = dmC64GetOpSubjectSize(op, fmt->format); 1030 size = dmC64GetOpSubjectSize(op, fmt->format);
1020 if (op->type == DO_COPY && op->offs + size > buf->len + 1) 1031 if (op->type == DO_COPY && op->offs + size > buf->len + 1)
1021 { 1032 {
1022 return dmError(DMERR_INVALID_DATA, 1033 return dmError(DMERR_INVALID_DATA,
1217 break; 1228 break;
1218 1229
1219 // Check operation validity 1230 // Check operation validity
1220 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK) 1231 if ((res = dmC64SanityCheckEncDecOp(i, op, img)) != DMERR_OK)
1221 goto err; 1232 goto err;
1233
1234 // Check flags
1235 if ((op->flags & DF_ENCODE) == 0)
1236 continue;
1222 1237
1223 // Do we need to reallocate some more space? 1238 // Do we need to reallocate some more space?
1224 size = dmC64GetOpSubjectSize(op, fmt->format); 1239 size = dmC64GetOpSubjectSize(op, fmt->format);
1225 chksize = buf->offs + op->offs + size; 1240 chksize = buf->offs + op->offs + size;
1226 if (!dmGrowBufCheckGrow(buf, chksize)) 1241 if (!dmGrowBufCheckGrow(buf, chksize))