cvs: php-src(PHP_5_2) /ext/date/lib parse_tz.c
| From: | Antony Dovgal | Date: | Thu, 25 Jan 2007 13:37:04 +0000 |
| Subject: | cvs: php-src(PHP_5_2) /ext/date/lib parse_tz.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-42879@lists.php.net to get a copy of this message | ||
tony2001 Thu Jan 25 13:37:04 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/date/lib parse_tz.c
Log:
setlocale() returns static buffer, which must be copied
http://cvs.php.net/viewvc.cgi/php-src/ext/date/lib/parse_tz.c?r1=1.20.2.6.2.10&r2=1.20.2.6.2.11&diff_format=u
Index: php-src/ext/date/lib/parse_tz.c
diff -u php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.10 php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.11
--- php-src/ext/date/lib/parse_tz.c:1.20.2.6.2.10 Thu Jan 18 23:20:24 2007
+++ php-src/ext/date/lib/parse_tz.c Thu Jan 25 13:37:04 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: parse_tz.c,v 1.20.2.6.2.10 2007/01/18 23:20:24 iliaa Exp $ */
+/* $Id: parse_tz.c,v 1.20.2.6.2.11 2007/01/25 13:37:04 tony2001 Exp $ */
#include "timelib.h"
@@ -196,7 +196,13 @@
static int seek_to_tz_position(const unsigned char **tzf, char *timezone, const timelib_tzdb *tzdb)
{
int left = 0, right = tzdb->index_size - 1;
- char *cur_locale = setlocale(LC_CTYPE, "C");
+ char *cur_locale = NULL, *tmp;
+
+ tmp = setlocale(LC_CTYPE, NULL);
+ if (tmp) {
+ cur_locale = strdup(tmp);
+ }
+ setlocale(LC_CTYPE, "C");
do {
int mid = ((unsigned)left + right) >> 1;
@@ -209,12 +215,14 @@
} else { /* (cmp == 0) */
(*tzf) = &(tzdb->data[tzdb->index[mid].pos + 20]);
setlocale(LC_CTYPE, cur_locale);
+ if (cur_locale) free(cur_locale);
return 1;
}
} while (left <= right);
setlocale(LC_CTYPE, cur_locale);
+ if (cur_locale) free(cur_locale);
return 0;
}