|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46948 ext/date/lib/parse_tz.c:99: Memory leak: buffer
Submitted: 2008-12-26 20:55 UTC Modified: 2021-04-07 09:23 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: dvice_null at yahoo dot com Assigned: derick (profile)
Status: No Feedback Package: Date/time related
PHP Version: 6CVS-2008-12-26 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: dvice_null at yahoo dot com
New email:
PHP Version: OS:


 [2008-12-26 20:55 UTC] dvice_null at yahoo dot com
In file ext/date/lib/parse_tz.c:99: 
Variable "buffer" leaks memory if "cbuffer" is null in this code:

if (!cbuffer) {

This bug was found using cppcheck:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-26 21:11 UTC] dvice_null at yahoo dot com
Two similar problems in the same file. Let me know if you want separate bug reports about these:


ext/date/lib/parse_tz.c:124]: Memory leak: buffer

if (!tz->type) {


ext/date/lib/parse_tz.c:152: Memory leak: leap_buffer

if (!tz->leap_times) {
 [2008-12-26 21:51 UTC]
I think something like this:

Index: ext/date/lib/parse_tz.c
RCS file: /repository/php-src/ext/date/lib/parse_tz.c,v
retrieving revision
diff -u -p -r1. parse_tz.c
--- ext/date/lib/parse_tz.c	9 Aug 2008 22:01:08 -0000
+++ ext/date/lib/parse_tz.c	26 Dec 2008 21:47:20 -0000
@@ -100,6 +100,7 @@ static void read_transistions(char **tzf
 		cbuffer = (unsigned char*) malloc(tz->timecnt * sizeof(unsigned char));
 		if (!cbuffer) {
+			free(buffer);
 		memcpy(cbuffer, *tzf, sizeof(unsigned char) * tz->timecnt);
@@ -125,6 +126,7 @@ static void read_types(char **tzf, timel
 	tz->type = (ttinfo*) malloc(tz->typecnt * sizeof(struct ttinfo));
 	if (!tz->type) {
+		free(buffer);
@@ -153,6 +155,9 @@ static void read_types(char **tzf, timel
 		tz->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo));
 		if (!tz->leap_times) {
+			free(leap_buffer);
+			free(tz->timezone_abbr);
+			free(tz->types);
 		for (i = 0; i < tz->leapcnt; i++) {

 [2008-12-26 21:59 UTC]
Truly, I think that Derick really free that vars. in another place.
 [2017-01-11 16:33 UTC]
Is this still an issue? Or can that be closed after 8 years and targeting an unsupported version?
 [2021-04-07 09:23 UTC]
-Status: Assigned +Status: No Feedback
 [2021-04-07 09:23 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Nov 30 10:03:44 2022 UTC