mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-26 05:18:21 +01:00
Make sure memory is freed on error conditions.
This commit is contained in:
parent
74dfefdcc1
commit
8f2c47cb07
@ -1064,9 +1064,6 @@ stream_read(pdfio_stream_t *st, // I - Stream
|
|||||||
st->flate.next_out = (Bytef *)buffer;
|
st->flate.next_out = (Bytef *)buffer;
|
||||||
st->flate.avail_out = (uInt)bytes;
|
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)
|
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));
|
_pdfioFileError(st->pdf, "Unable to decompress stream data for object %ld: %s", (long)st->obj->number, zstrerror(status));
|
||||||
|
8
ttf.c
8
ttf.c
@ -1309,6 +1309,8 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
if (segment->startCode > segment->endCode)
|
if (segment->startCode > segment->endCode)
|
||||||
{
|
{
|
||||||
errorf(font, "Bad cmap table segment %u to %u.", segments->startCode, segment->endCode);
|
errorf(font, "Bad cmap table segment %u to %u.", segments->startCode, segment->endCode);
|
||||||
|
free(segments);
|
||||||
|
free(glyphIdArray);
|
||||||
return (false);
|
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)
|
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
{
|
{
|
||||||
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
free(segments);
|
||||||
|
free(glyphIdArray);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1422,6 +1426,7 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
if (group->startCharCode > group->endCharCode)
|
if (group->startCharCode > group->endCharCode)
|
||||||
{
|
{
|
||||||
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
|
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
|
||||||
|
free(groups);
|
||||||
return (false);
|
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)
|
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
{
|
{
|
||||||
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
free(groups);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1511,6 +1517,7 @@ read_cmap(ttf_t *font) // I - Font
|
|||||||
if (group->startCharCode > group->endCharCode)
|
if (group->startCharCode > group->endCharCode)
|
||||||
{
|
{
|
||||||
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
|
errorf(font, "Bad cmap table segment %u to %u.", group->startCharCode, group->endCharCode);
|
||||||
|
free(groups);
|
||||||
return (false);
|
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)
|
if (font->num_cmap == 0 || font->num_cmap > TTF_FONT_MAX_CHAR)
|
||||||
{
|
{
|
||||||
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
errorf(font, "Invalid cmap table with %u characters.", (unsigned)font->num_cmap);
|
||||||
|
free(groups);
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user