Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 53f9f00d02359ec7645f6d022714ae47 > files > 3

gawk-3.1.5-16.el5.src.rpm

From ca82d394f29a5723b1fc9a183e995ee37ef43300 Mon Sep 17 00:00:00 2001
From: "Vojtech Vitek (V-Teq)" <vvitek@redhat.com>
Date: Mon, 17 Oct 2011 02:17:42 +0200
Subject: [PATCH] Fix double free in free_wstr

---
 node.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/node.c b/node.c
index 795cc2e..76fb533 100644
--- a/node.c
+++ b/node.c
@@ -690,6 +690,15 @@ str2wstr(NODE *n, size_t **ptr)
 
 	assert((n->flags & (STRING|STRCUR)) != 0);
 
+	/*
+	 * Don't convert global null string or global null field
+	 * variables to a wide string. They are both zero-length anyway.
+	 * This also avoids future double-free errors while releasing
+	 * shallow copies, eg. *tmp = *Null_field; free_wstr(tmp);
+	 */
+	if (n == Nnull_string || n == Null_field)
+		return n;
+
 	if ((n->flags & WSTRCUR) != 0) {
 		if (ptr == NULL)
 			return n;
-- 
1.7.6.2