Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 921:2454ddb7363f
Add constant for max number of enc/dec ops in C64 image format struct
and check the specified amount against that.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 25 Feb 2015 14:19:46 +0200 |
parents | 9be156fa4b9d |
children | 0f477446448d |
comparison
equal
deleted
inserted
replaced
920:9be156fa4b9d | 921:2454ddb7363f |
---|---|
608 int i; | 608 int i; |
609 | 609 |
610 if (buf == NULL || img == NULL || fmt == NULL) | 610 if (buf == NULL || img == NULL || fmt == NULL) |
611 return DMERR_NULLPTR; | 611 return DMERR_NULLPTR; |
612 | 612 |
613 if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS) | |
614 { | |
615 dmError("Invalid number of enc/dec ops in format. Internal error.\n"); | |
616 return DMERR_INTERNAL; | |
617 } | |
618 | |
613 // Clear the image structure | 619 // Clear the image structure |
614 memset(img, 0, sizeof(*img)); | 620 memset(img, 0, sizeof(*img)); |
615 img->type = fmt->type; | 621 img->type = fmt->type; |
616 | 622 |
617 // Perform decoding | 623 // Perform decoding |
735 Uint8 *buf; | 741 Uint8 *buf; |
736 size_t allocated; | 742 size_t allocated; |
737 | 743 |
738 if (pbuf == NULL || plen == NULL || img == NULL || fmt == NULL) | 744 if (pbuf == NULL || plen == NULL || img == NULL || fmt == NULL) |
739 return DMERR_NULLPTR; | 745 return DMERR_NULLPTR; |
746 | |
747 if (fmt->nencdecOps < 0 || fmt->nencdecOps >= D64_MAX_ENCDEC_OPS) | |
748 { | |
749 dmError("Invalid number of enc/dec ops in format. Internal error.\n"); | |
750 return DMERR_INTERNAL; | |
751 } | |
740 | 752 |
741 // Allocate the output buffer | 753 // Allocate the output buffer |
742 *plen = 0; | 754 *plen = 0; |
743 if (fmt->size > 0) | 755 if (fmt->size > 0) |
744 *plen = allocated = fmt->size; | 756 *plen = allocated = fmt->size; |