summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuière <hub@figuiere.net>2017-08-03 21:53:04 -0400
committerHubert Figuière <hub@figuiere.net>2017-08-03 21:53:04 -0400
commitf19d0107fbae1fb41836cd110d4425e407e64048 (patch)
tree9e7e81d6dc1165b3495daed741025a21d7d9081f
parent9e76a7782a54a242f18d609e7ba32bf1c430a5e4 (diff)
Bug 101914 - Fix crash on corrupt file
- Don't go past the end iterator - Don't subcript an empty string
-rw-r--r--XMPFiles/source/FormatSupport/PostScript_Support.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/XMPFiles/source/FormatSupport/PostScript_Support.cpp b/XMPFiles/source/FormatSupport/PostScript_Support.cpp
index fec55fb..029ff0c 100644
--- a/XMPFiles/source/FormatSupport/PostScript_Support.cpp
+++ b/XMPFiles/source/FormatSupport/PostScript_Support.cpp
@@ -814,7 +814,8 @@ std::string PostScript_Support::ConvertToDate(const char* inString)
std::vector<PostScript_Support::DateTimeTokens>:: const_iterator itr=tokenzs.begin();
for(;itr!=tokenzs.end();itr++)
{
- if(itr->token[0]=='+' ||itr->token[0]=='-')
+ // token[0] is invalid on an empty string. -- Hub
+ if(!itr->token.empty() && (itr->token[0]=='+' ||itr->token[0]=='-'))
{
const char *str=itr->token.c_str();
date.offsetSign=*(str++);
@@ -1013,7 +1014,14 @@ std::string PostScript_Support::ConvertToDate(const char* inString)
if(itr!=tokenzs.end())
{
++itr;
- if (itr!=tokenzs.end()&&itr->noOfDelimiter==0 && IsNumeric(itr->token[0]) )
+ if (itr == tokenzs.end())
+ {
+ // bug 101914 - corrupt file make us
+ // reach the end. -- Hub
+ // https://bugs.freedesktop.org/show_bug.cgi?id=101914
+ break;
+ }
+ if (itr->noOfDelimiter==0 && IsNumeric(itr->token[0]) )
{
const char * str=itr->token.c_str();
short day= GetNumber(&str);