From 8c53f8b47773114c3902508c35ecd4e64cb03b47 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 28 Jan 2012 15:07:00 +0000 Subject: [PATCH] Detect failure of mktime(), return error --- ext/POSIX/POSIX.xs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 715807d..d157317 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -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))); -- 1.8.3.1