Save work on resolving PDF loading issues with random PDFs using different encryption methods and line endings.

This commit is contained in:
Michael R Sweet
2021-11-01 21:30:46 -04:00
parent 6432187dea
commit 2f0d622873
5 changed files with 103 additions and 20 deletions

View File

@@ -396,20 +396,27 @@ pdfioArrayGetBinary(
size_t n, // I - Index
size_t *length) // O - Length of string
{
if (!a || n >= a->num_values || a->values[n].type != PDFIO_VALTYPE_BINARY)
if (!a || n >= a->num_values || (a->values[n].type != PDFIO_VALTYPE_BINARY && a->values[n].type != PDFIO_VALTYPE_STRING))
{
if (length)
*length = 0;
return (NULL);
}
else
else if (a->values[n].type == PDFIO_VALTYPE_BINARY)
{
if (length)
*length = a->values[n].value.binary.datalen;
return (a->values[n].value.binary.data);
}
else
{
if (length)
*length = strlen(a->values[n].value.string);
return ((unsigned char *)a->values[n].value.string);
}
}