[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] getdate: don't leak when TZ contains two or more '"'s
From: |
Jim Meyering |
Subject: |
[PATCH] getdate: don't leak when TZ contains two or more '"'s |
Date: |
Mon, 18 Jan 2010 08:27:35 +0100 |
FYI, this potential leak was spotted via coverity,
as was the one that prompted today's readtokens fix.
>From 2e3e4195c0c15b836ec60652a1b3b06d81767a2f Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 18 Jan 2010 08:23:24 +0100
Subject: [PATCH] getdate: don't leak when TZ contains two or more '"'s
* lib/getdate.y (get_date): Don't leak a copy of TZ for each
double quote in TZ after the first one.
---
ChangeLog | 4 ++++
lib/getdate.y | 2 ++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 42257ee..7171d59 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2010-01-18 Jim Meyering <address@hidden>
+ getdate: don't leak when TZ contains two or more '"'s
+ * lib/getdate.y (get_date): Don't leak a copy of TZ for each
+ double quote in TZ after the first one.
+
readtokens: do not leak internal token_lengths buffer
* lib/readtokens.c (readtokens): Free the local, lengths,
when the supplied "token_lengths" parameter is NULL.
diff --git a/lib/getdate.y b/lib/getdate.y
index e8c5233..445865b 100644
--- a/lib/getdate.y
+++ b/lib/getdate.y
@@ -1252,6 +1252,8 @@ get_date (struct timespec *result, char const *p, struct
timespec const *now)
char tz1buf[TZBUFSIZE];
bool large_tz = TZBUFSIZE < tzsize;
bool setenv_ok;
+ /* Free tz0, in case this is the 2nd or subsequent time through. */
+ free (tz0);
tz0 = get_tz (tz0buf);
z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
for (s = tzbase; *s != '"'; s++)
--
1.6.6.638.g2bc54
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] getdate: don't leak when TZ contains two or more '"'s,
Jim Meyering <=