diff --git a/CHANGES.md b/CHANGES.md index 58df7ea..59ccc03 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ v1.5.1 - YYYY-MM-DD - Fixed output of special characters in name values (Issue #106) - Fixed output of special characters in string values (Issue #107) - Fixed output of large integers in dictionaries (Issue #108) +- Fixed handling of 0-length streams (Issue #111) v1.5.0 - 2025-03-06 diff --git a/pdfio-object.c b/pdfio-object.c index 3829026..055ffb4 100644 --- a/pdfio-object.c +++ b/pdfio-object.c @@ -307,7 +307,8 @@ pdfioObjGetLength(pdfio_obj_t *obj) // I - Object if ((lenobj = pdfioDictGetObj(obj->value.value.dict, "Length")) == NULL) { - _pdfioFileError(obj->pdf, "Unable to get length of stream."); + if (!_pdfioDictGetValue(obj->value.value.dict, "Length")) + _pdfioFileError(obj->pdf, "Unable to get length of stream."); return (0); } diff --git a/pdfio-stream.c b/pdfio-stream.c index 885eb78..bc3658b 100644 --- a/pdfio-stream.c +++ b/pdfio-stream.c @@ -439,7 +439,7 @@ _pdfioStreamOpen(pdfio_obj_t *obj, // I - Object st->pdf = obj->pdf; st->obj = obj; - if ((st->remaining = pdfioObjGetLength(obj)) == 0) + if ((st->remaining = pdfioObjGetLength(obj)) == 0 && !_pdfioDictGetValue(pdfioObjGetDict(obj), "Length")) { _pdfioFileError(obj->pdf, "No stream data."); goto error;