]> granicus.if.org Git - python/commitdiff
correct static string clearing loop (closes #16906)
authorBenjamin Peterson <benjamin@python.org>
Wed, 9 Jan 2013 15:52:01 +0000 (09:52 -0600)
committerBenjamin Peterson <benjamin@python.org>
Wed, 9 Jan 2013 15:52:01 +0000 (09:52 -0600)
Misc/NEWS
Objects/unicodeobject.c

index e3fd61c8911bfa143affcb17d5f52963e96e105e..6ed6101635bb56135052064d66e4ce8483e85b73 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.3.1?
 Core and Builtins
 -----------------
 
+- Issue #16906: Fix a logic error that prevented most static strings from being
+  cleared.
+
 - Issue #11461: Fix the incremental UTF-16 decoder. Original patch by
   Amaury Forgeot d'Arc.
 
index b4fc0040b6e5923b5a2647d938f749296acebe5d..16d59292eff2e0586ae1a4df8967c20680a79ffe 100644 (file)
@@ -1826,12 +1826,15 @@ _PyUnicode_FromId(_Py_Identifier *id)
 void
 _PyUnicode_ClearStaticStrings()
 {
-    _Py_Identifier *i;
-    for (i = static_strings; i; i = i->next) {
-        Py_DECREF(i->object);
-        i->object = NULL;
-        i->next = NULL;
-    }
+    _Py_Identifier *tmp, *s = static_strings;
+    while (s) {
+        Py_DECREF(s->object);
+        s->object = NULL;
+        tmp = s->next;
+        s->next = NULL;
+        s = tmp;
+    }
+    static_strings = NULL;
 }
 
 /* Internal function, doesn't check maximum character */