Make sure memory is freed on error conditions.

This commit is contained in:
Michael R Sweet 2024-10-09 15:32:48 -04:00
parent 74dfefdcc1
commit 8f2c47cb07
No known key found for this signature in database
GPG Key ID: BE67C75EC81F3244
2 changed files with 8 additions and 3 deletions

View File

@ -1064,9 +1064,6 @@ stream_read(pdfio_stream_t *st, // I - Stream
st->flate.next_out = (Bytef *)buffer;
st->flate.avail_out = (uInt)bytes;
avail_in = st->flate.avail_in;
avail_out = st->flate.avail_out;
if ((status = inflate(&(st->flate), Z_NO_FLUSH)) < Z_OK)
{
_pdfioFileError(st->pdf, "Unable to decompress stream data for object %ld: %s", (long)st->obj->number, zstrerror(status));

8
ttf.c
View File

@ -1309,6 +1309,8 @@ read_cmap(ttf_t *font) // I - Font
if (segment->startCode > segment->endCode)
{
errorf(font, "Bad cmap table segment %u to %u.", segments->startCode, segment->endCode);
free(segments);
free(glyphIdArray);
return (false);
}
@ -1326,6 +1328,8 @@ read_cmap(ttf_t *font) // I - Font
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
{
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
free(segments);
free(glyphIdArray);
return (false);
}
@ -1422,6 +1426,7 @@ read_cmap(ttf_t *font) // I - Font
if (group->startCharCode > group->endCharCode)
{
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
free(groups);
return (false);
}
@ -1436,6 +1441,7 @@ read_cmap(ttf_t *font) // I - Font
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
{
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
free(groups);
return (false);
}
@ -1511,6 +1517,7 @@ read_cmap(ttf_t *font) // I - Font
if (group->startCharCode > group->endCharCode)
{
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
free(groups);
return (false);
}
@ -1525,6 +1532,7 @@ read_cmap(ttf_t *font) // I - Font
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
{
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
free(groups);
return (false);
}