Hello Everyone,
This extensions conflicts with pecl/date. Two extensions with the same
name makes it impossible to build any of these. Any resolutions for this?
- Frank
iliaa Tue Jun 14 19:40:57 2005 EDT
Modified files:
/php-src/ext/date php_date.c
/php-src/ext/date/lib datetime.c
Log:
Fixed memory leaks.
http://cvs.php.net/diff.php/php-src/ext/date/php_date.c?r1=1.1r2=1.2ty=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.1 php-src/ext/date/php_date.c:1.2
--- php-src/ext/date/php_date.c:1.1 Tue Jun 14 17:32:27 2005
+++ php-src/ext/date/php_date.c Tue Jun 14 19:40:56 2005
@@ -16,7 +16,7 @@
+--+
*/
-/* $Id: php_date.c,v 1.1 2005/06/14 21:32:27 derick Exp $ */
+/* $Id: php_date.c,v 1.2 2005/06/14 23:40:56 iliaa Exp $ */
#include php.h
#include php_streams.h
@@ -128,6 +128,7 @@
now = timelib_time_ctor();
timelib_unixtime2local(now, (signed long long) time(NULL), tzi);
} else {
+ timelib_tzinfo_ctor(tzi);
RETURN_FALSE;
}
@@ -135,6 +136,16 @@
timelib_fill_holes(t, now, 0);
timelib_update_ts(t, tzi);
ts = timelib_date_to_int(t, error);
+
+ /* if tz_info is not a copy, avoid double free */
+ if (now-tz_info == tzi) {
+ now-tz_info = NULL;
+ }
+
+ timelib_time_dtor(now);
+ timelib_time_dtor(t);
+ timelib_tzinfo_dtor(tzi);
+
if (error) {
RETURN_FALSE;
} else {
http://cvs.php.net/diff.php/php-src/ext/date/lib/datetime.c?r1=1.1r2=1.2ty=u
Index: php-src/ext/date/lib/datetime.c
diff -u php-src/ext/date/lib/datetime.c:1.1
php-src/ext/date/lib/datetime.c:1.2
--- php-src/ext/date/lib/datetime.c:1.1 Tue Jun 14 17:32:27 2005
+++ php-src/ext/date/lib/datetime.c Tue Jun 14 19:40:57 2005
@@ -16,12 +16,18 @@
+--+
*/
-/* $Id: datetime.c,v 1.1 2005/06/14 21:32:27 derick Exp $ */
+/* $Id: datetime.c,v 1.2 2005/06/14 23:40:57 iliaa Exp $ */
#include timelib_structs.h
#include datetime.h
#include ctype.h
+#define PHP_TIME_FREE(m) + if (m) {+
free(m);+ m = NULL; + }
+
timelib_time* timelib_time_ctor()
{
timelib_time *t;
@@ -33,10 +39,8 @@
void timelib_time_tz_abbr_update(timelib_time* tm, char* tz_abbr)
{
int i;
-
- if (tm-tz_abbr) {
- free(tm-tz_abbr);
- }
+
+ PHP_TIME_FREE(tm-tz_abbr);
tm-tz_abbr = strdup(tz_abbr);
for (i = 0; i strlen(tz_abbr); i++) {
tm-tz_abbr[i] = toupper(tz_abbr[i]);
@@ -45,10 +49,12 @@
void timelib_time_dtor(timelib_time* t)
{
- if (t-tz_abbr) {
- free(t-tz_abbr);
+ PHP_TIME_FREE(t-tz_abbr);
+ if (t-tz_info) {
+ timelib_tzinfo_dtor(t-tz_info);
+ t-tz_info = NULL;
}
- free(t);
+ PHP_TIME_FREE(t);
}
timelib_time_offset* timelib_time_offset_ctor()
@@ -61,10 +67,8 @@
void timelib_time_offset_dtor(timelib_time_offset* t)
{
- if (t-abbr) {
- free(t-abbr);
- }
- free(t);
+ PHP_TIME_FREE(t-abbr);
+ PHP_TIME_FREE(t);
}
timelib_tzinfo* timelib_tzinfo_ctor(char *name)
@@ -105,13 +109,13 @@
void timelib_tzinfo_dtor(timelib_tzinfo *tz)
{
- free(tz-name);
- free(tz-trans);
- free(tz-trans_idx);
- free(tz-type);
- free(tz-timezone_abbr);
- free(tz-leap_times);
- free(tz);
+ PHP_TIME_FREE(tz-name);
+ PHP_TIME_FREE(tz-trans);
+ PHP_TIME_FREE(tz-trans_idx);
+ PHP_TIME_FREE(tz-type);
+ PHP_TIME_FREE(tz-timezone_abbr);
+ PHP_TIME_FREE(tz-leap_times);
+ PHP_TIME_FREE(tz);
}
char *timelib_get_tz_abbr_ptr(timelib_time *t)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php