]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #38524 (strptime() does not initialize the internal date
authorIlia Alshanetsky <iliaa@php.net>
Sun, 20 Aug 2006 18:20:59 +0000 (18:20 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 20 Aug 2006 18:20:59 +0000 (18:20 +0000)
storage structure).

ext/standard/datetime.c
ext/standard/tests/time/bug38524.phpt [new file with mode: 0755]

index 5e791f21cfe3b7f62761300d6fadf05c777b6586..7e2a5b44347eb648a0c4d33d11e9e5b3c42bc16c 100644 (file)
@@ -101,6 +101,8 @@ PHP_FUNCTION(strptime)
                return;
        }
 
+       memset(&parsed_time, 0, sizeof(parsed_time));
+
        unparsed_part = strptime(ts, format, &parsed_time);
        if (unparsed_part == NULL) {
                RETURN_FALSE;
diff --git a/ext/standard/tests/time/bug38524.phpt b/ext/standard/tests/time/bug38524.phpt
new file mode 100755 (executable)
index 0000000..4a2abe9
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+Bug #38524 (strptime() does not initialize the internal date storage structure)
+--FILE--
+<?php
+       var_dump(strptime('2006-08-20', '%Y-%m-%d'));
+?>
+===DONE===
+--EXPECT--
+array(9) {
+  ["tm_sec"]=>
+  int(0)
+  ["tm_min"]=>
+  int(0)
+  ["tm_hour"]=>
+  int(0)
+  ["tm_mday"]=>
+  int(20)
+  ["tm_mon"]=>
+  int(7)
+  ["tm_year"]=>
+  int(106)
+  ["tm_wday"]=>
+  int(0)
+  ["tm_yday"]=>
+  int(231)
+  ["unparsed"]=>
+  string(0) ""
+}
+===DONE===