Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1808)

Unified Diff: patches/nss-secitem-array-leak.patch

Issue 14704003: Fix a memory leak in SECITEM_FreeArray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/nss/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nss/lib/util/secitem.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: patches/nss-secitem-array-leak.patch
===================================================================
--- patches/nss-secitem-array-leak.patch (revision 0)
+++ patches/nss-secitem-array-leak.patch (revision 0)
@@ -0,0 +1,43 @@
+diff --git a/lib/util/secitem.c b/lib/util/secitem.c
+--- a/lib/util/secitem.c
++++ b/lib/util/secitem.c
+@@ -353,17 +352,18 @@ loser:
+ /*
+ * If array is not NULL, the above has set array->data and
+ * array->len to 0.
+ */
+ }
+ return(NULL);
+ }
+
+-void secitem_FreeArray(SECItemArray *array, PRBool zero_items, PRBool freeit)
++static void
++secitem_FreeArray(SECItemArray *array, PRBool zero_items, PRBool freeit)
+ {
+ unsigned int i;
+
+ if (!array || !array->len || !array->items)
+ return;
+
+ for (i=0; i<array->len; ++i) {
+ SECItem *item = &array->items[i];
+@@ -371,16 +371,19 @@ void secitem_FreeArray(SECItemArray *arr
+ if (item->data) {
+ if (zero_items) {
+ SECITEM_ZfreeItem(item, PR_FALSE);
+ } else {
+ SECITEM_FreeItem(item, PR_FALSE);
+ }
+ }
+ }
++ PORT_Free(array->items);
++ array->items = NULL;
++ array->len = 0;
+
+ if (freeit)
+ PORT_Free(array);
+ }
+
+ void SECITEM_FreeArray(SECItemArray *array, PRBool freeit)
+ {
+ secitem_FreeArray(array, PR_FALSE, freeit);
« no previous file with comments | « nss/lib/util/secitem.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698