Fix a DateTime leak
commitbc5778169eb8cb06bb4fec46826aa6681be722ab
authormwilliams <mwilliams@fb.com>
Sat, 6 Jul 2013 17:11:05 +0000 (6 10:11 -0700)
committerSara Golemon <sgolemon@fb.com>
Mon, 8 Jul 2013 17:30:57 +0000 (8 10:30 -0700)
tree0267cbf7e8487a3c6009dd38f0c37a422c0ed8a6
parentd336b46cc74ac7c276fec366e18943d576c02d93
Fix a DateTime leak

D860568 fixed a double free, but introduced a leak. If no
timezone is specified in the input string, timelib_fill_holes
would clone the one from m_time. Since we unconditionally cloned
*that* into m_tz, the clone from timelib_fill_holes was leaked.

The contract seems to be that m_time doesn't own it's tz_info, but
that it should be owned by a smart pointer somewhere. So we can tell
timelib_fill_holes *not* to clone the tz_info from its second parameter,
and at the same time optimize for the usual case where that timezone
is already the current timezone.
hphp/runtime/base/time/datetime.cpp
hphp/test/slow/ext_datetime/strtotime_leak.php [new file with mode: 0644]
hphp/test/slow/ext_datetime/strtotime_leak.php.expect [new file with mode: 0644]