diff -rupN poppler-0.67.0/utils/pdfdetach.cc poppler-0.67.0-new/utils/pdfdetach.cc --- poppler-0.67.0/utils/pdfdetach.cc 2019-02-20 19:27:38.420686081 +0100 +++ poppler-0.67.0-new/utils/pdfdetach.cc 2019-02-20 19:27:38.422686082 +0100 @@ -190,14 +190,18 @@ int main(int argc, char *argv[]) { fileSpec = static_cast(embeddedFiles->get(i)); printf("%d: ", i+1); s1 = fileSpec->getFileName(); - if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) { + if (!s1) { + exitCode = 3; + goto err2; + } + if (s1->hasUnicodeMarker()) { isUnicode = gTrue; j = 2; } else { isUnicode = gFalse; j = 0; } - while (j < fileSpec->getFileName()->getLength()) { + while (j < s1->getLength()) { if (isUnicode) { u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff); j += 2; @@ -227,14 +231,18 @@ int main(int argc, char *argv[]) { p = path; } s1 = fileSpec->getFileName(); - if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) { + if (!s1) { + exitCode = 3; + goto err2; + } + if (s1->hasUnicodeMarker()) { isUnicode = gTrue; j = 2; } else { isUnicode = gFalse; j = 0; } - while (j < fileSpec->getFileName()->getLength()) { + while (j < s1->getLength()) { if (isUnicode) { u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff); j += 2; @@ -275,14 +283,18 @@ int main(int argc, char *argv[]) { } else { p = path; s1 = fileSpec->getFileName(); - if ((s1->getChar(0) & 0xff) == 0xfe && (s1->getChar(1) & 0xff) == 0xff) { + if (!s1) { + exitCode = 3; + goto err2; + } + if (s1->hasUnicodeMarker()) { isUnicode = gTrue; j = 2; } else { isUnicode = gFalse; j = 0; } - while (j < fileSpec->getFileName()->getLength()) { + while (j < s1->getLength()) { if (isUnicode) { u = ((s1->getChar(j) & 0xff) << 8) | (s1->getChar(j+1) & 0xff); j += 2;