Skip to content

Commit a81907b

Browse files
committed
Refactor get_info_string to rely on pdfioDictGetString to convert binary strings to regular ones.
1 parent 63a7a2c commit a81907b

File tree

1 file changed

+3
-26
lines changed

1 file changed

+3
-26
lines changed

pdfio-file.c

+3-26
Original file line numberDiff line numberDiff line change
@@ -1412,36 +1412,13 @@ get_info_string(pdfio_file_t *pdf, // I - PDF file
14121412
const char *key) // I - Dictionary key
14131413
{
14141414
pdfio_dict_t *dict; // Info dictionary
1415-
_pdfio_value_t *value; // Value
1415+
14161416

14171417
// Range check input...
1418-
if (!pdf || !pdf->info_obj || (dict = pdfioObjGetDict(pdf->info_obj)) == NULL || (value = _pdfioDictGetValue(dict, key)) == NULL)
1418+
if (!pdf || !pdf->info_obj || (dict = pdfioObjGetDict(pdf->info_obj)) == NULL)
14191419
return (NULL);
1420-
1421-
// If we already have a value, return it...
1422-
if (value->type == PDFIO_VALTYPE_NAME || value->type == PDFIO_VALTYPE_STRING)
1423-
{
1424-
return (value->value.string);
1425-
}
1426-
else if (value->type == PDFIO_VALTYPE_BINARY && value->value.binary.datalen < 4096)
1427-
{
1428-
// Convert binary string to regular string...
1429-
char temp[4096]; // Temporary string
1430-
1431-
memcpy(temp, value->value.binary.data, value->value.binary.datalen);
1432-
temp[value->value.binary.datalen] = '\0';
1433-
1434-
free(value->value.binary.data);
1435-
value->type = PDFIO_VALTYPE_STRING;
1436-
value->value.string = pdfioStringCreate(pdf, temp);
1437-
1438-
return (value->value.string);
1439-
}
14401420
else
1441-
{
1442-
// Something else that is not a string...
1443-
return (NULL);
1444-
}
1421+
return (pdfioDictGetString(dict, key));
14451422
}
14461423

14471424

0 commit comments

Comments
 (0)