Detect failure of mktime(), return error
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>
Sat, 28 Jan 2012 15:07:00 +0000 (15:07 +0000)
committerÆvar Arnfjörð Bjarmason <avar@cpan.org>
Sat, 11 Feb 2012 22:22:24 +0000 (22:22 +0000)
ext/POSIX/POSIX.xs

index 715807d..d157317 100644 (file)
@@ -1903,8 +1903,10 @@ strptime(str, fmt, sec=-1, min=-1, hour=-1, mday=-1, mon=-1, year=-1, wday=-1, y
                posmg->mg_len = remains - str_base;
            }
 
-           if(tm.tm_mday > -1 && tm.tm_mon > -1 && tm.tm_year > -1)
-               mktime(&tm);
+           if(tm.tm_mday > -1 && tm.tm_mon > -1 && tm.tm_year > -1) {
+               if(mktime(&tm) == (time_t)-1)
+                   XSRETURN(0);
+           }
 
            EXTEND(SP, 9);
            PUSHs(sv_2mortal(newSViv(tm.tm_sec)));