gawk/gawk-3.1.8-double-free-wstp...

24 lines
710 B
Diff

Index: node.c
===================================================================
RCS file: /sources/gawk/gawk-devel/node.c,v
retrieving revision 1.3
diff -u -r1.3 node.c
--- node.c 6 May 2010 19:00:58 -0000 1.3
+++ node.c 27 Oct 2010 17:56:49 -0000
@@ -758,6 +758,15 @@
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;