Skip to content

Commit 371000a

Browse files
committed
Fixed bug #64359 strftime crash with VS2012
1 parent 9ed7eab commit 371000a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ PHP NEWS
1313
- PCRE:
1414
. Merged PCRE 8.32. (Anatol)
1515

16+
- DateTime:
17+
. Fixed bug #64359 (strftime crash with VS2012). (Anatol)
18+
1619
21 Feb 2013, PHP 5.5.0 Alpha 5
1720

1821
- Core:

ext/date/php_date.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,17 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, int gmt)
15741574
long timestamp = 0;
15751575
struct tm ta;
15761576
int max_reallocs = 5;
1577-
size_t buf_len = 64, real_len;
1577+
#ifdef PHP_WIN32
1578+
/* VS2012 has a bug where strftime crash with %z and %Z format when the
1579+
initial buffer is too small. Increasing the buffer size helps in a
1580+
workaround to fixs longer format strings for this VS version.
1581+
http://connect.microsoft.com/VisualStudio/feedback/details/759720/vs2012-strftime-crash-with-z-formatting-code
1582+
*/
1583+
size_t buf_len = 256;
1584+
#else
1585+
size_t buf_len = 64;
1586+
#endif
1587+
size_t real_len;
15781588
timelib_time *ts;
15791589
timelib_tzinfo *tzi;
15801590
timelib_time_offset *offset = NULL;

0 commit comments

Comments
 (0)