Skip to content

Commit ebd5aab

Browse files
committed
Fix handling of 0-length streams (Issue #111)
1 parent 71d33c0 commit ebd5aab

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ v1.5.1 - YYYY-MM-DD
77
- Fixed output of special characters in name values (Issue #106)
88
- Fixed output of special characters in string values (Issue #107)
99
- Fixed output of large integers in dictionaries (Issue #108)
10+
- Fixed handling of 0-length streams (Issue #111)
1011

1112

1213
v1.5.0 - 2025-03-06

pdfio-object.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ pdfioObjGetLength(pdfio_obj_t *obj) // I - Object
307307

308308
if ((lenobj = pdfioDictGetObj(obj->value.value.dict, "Length")) == NULL)
309309
{
310-
_pdfioFileError(obj->pdf, "Unable to get length of stream.");
310+
if (!_pdfioDictGetValue(obj->value.value.dict, "Length"))
311+
_pdfioFileError(obj->pdf, "Unable to get length of stream.");
311312
return (0);
312313
}
313314

pdfio-stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ _pdfioStreamOpen(pdfio_obj_t *obj, // I - Object
439439
st->pdf = obj->pdf;
440440
st->obj = obj;
441441

442-
if ((st->remaining = pdfioObjGetLength(obj)) == 0)
442+
if ((st->remaining = pdfioObjGetLength(obj)) == 0 && !_pdfioDictGetValue(pdfioObjGetDict(obj), "Length"))
443443
{
444444
_pdfioFileError(obj->pdf, "No stream data.");
445445
goto error;

0 commit comments

Comments
 (0)