mirror of
https://github.com/rupertwh/bmplib.git
synced 2026-02-04 00:04:33 +00:00
icons/pointers/arrays: minor changes to error handling
This commit is contained in:
@@ -125,8 +125,12 @@ bool icon_read_array(BMPREAD_R rp)
|
||||
s_array_header_from_file_header(&ah, rp->fh);
|
||||
|
||||
while (n < nmax) {
|
||||
if (ah.type != BMPFILE_BA)
|
||||
if (ah.type != BMPFILE_BA) {
|
||||
logerr(rp->c.log, "Invalid BMP type (0x%04x), expected 'BA'", (unsigned) ah.type);
|
||||
invalid = true;
|
||||
rp->lasterr = BMP_ERR_HEADER;
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(&imgs[n].ah, &ah, sizeof ah);
|
||||
|
||||
@@ -139,10 +143,13 @@ bool icon_read_array(BMPREAD_R rp)
|
||||
bmp_free(imgs[n].handle);
|
||||
invalid = true;
|
||||
rp->lasterr = BMP_ERR_HEADER;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
logerr(rp->c.log, "Failed to create handle for array image");
|
||||
invalid = true;
|
||||
rp->lasterr = BMP_ERR_HEADER;
|
||||
rp->lasterr = BMP_ERR_MEMORY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ah.offsetnext)
|
||||
|
||||
@@ -802,7 +802,7 @@ static bool s_is_bmptype_supported(BMPREAD_R rp)
|
||||
{
|
||||
if (rp->ih->planes != 1) {
|
||||
logerr(rp->c.log, "Unsupported number of planes (%d). Must be 1.", (int) rp->ih->planes);
|
||||
rp->lasterr = BMP_ERR_HEADER;
|
||||
rp->lasterr = BMP_ERR_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -810,21 +810,25 @@ static bool s_is_bmptype_supported(BMPREAD_R rp)
|
||||
if (rp->ih->compression != BI_RGB) {
|
||||
logerr(rp->c.log, "Unsupported compression %s for icon/pointer",
|
||||
s_compression_name(rp->ih->compression));
|
||||
rp->lasterr = BMP_ERR_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
if (rp->ih->bitcount > 32) {
|
||||
logerr(rp->c.log, "Unsupported bitcount %d for icon/pointer",
|
||||
(int) rp->ih->bitcount);
|
||||
rp->lasterr = BMP_ERR_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
if (rp->ih->version > BMPINFO_OS22) {
|
||||
logerr(rp->c.log, "Unsupported header version %s for icon/pointer",
|
||||
cm_infoheader_name(rp->ih->version));
|
||||
rp->lasterr = BMP_ERR_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
if (rp->result_format != BMP_FORMAT_INT) {
|
||||
logerr(rp->c.log, "Chosen number format %s is incompatible with icon/pointer",
|
||||
cm_format_name(rp->result_format));
|
||||
rp->lasterr = BMP_ERR_UNSUPPORTED;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user