From: Gurusamy Sarathy <gsar@cpan.org>
Date: Sun, 5 Apr 1998 23:32:33 +0000 (+0000)
Subject: [win32] fix memory leaks in offer_nice_chunk()
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fc80cf79f6ce54c5e5487bc877eda643ef0d8104;p=p5sagit%2Fp5-mst-13.2.git

[win32] fix memory leaks in offer_nice_chunk()

p4raw-id: //depot/win32/perl@882
---

diff --git a/perl.h b/perl.h
index cd0f2bb..27e7241 100644
--- a/perl.h
+++ b/perl.h
@@ -2063,6 +2063,9 @@ enum {
 	    nice_chunk = (char*)(chunk);		\
 	    nice_chunk_size = (chunk_size);		\
 	}						\
+	else {						\
+	    Safefree(chunk);				\
+	}						\
 	UNLOCK_SV_MUTEX;				\
     } while (0)
 
diff --git a/sv.c b/sv.c
index 2711551..ff99867 100644
--- a/sv.c
+++ b/sv.c
@@ -400,6 +400,10 @@ sv_free_arenas(void)
 	    Safefree((void *)sva);
     }
 
+    if (nice_chunk)
+	Safefree(nice_chunk);
+    nice_chunk = Nullch;
+    nice_chunk_size = 0;
     sv_arenaroot = 0;
     sv_root = 0;
 }