This adds a leak, but fixes a crash. The leaking code is:
"{0:.{precision}s}".format('hello world', precision=5)
I pretty sure it's because of the 'precision' keyword.
Still need to investigate further.
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h
index 2799141..4ae7e57 100644
--- a/Objects/stringlib/string_format.h
+++ b/Objects/stringlib/string_format.h
@@ -416,6 +416,7 @@
Py_DECREF(key);
goto error;
}
+ Py_INCREF(obj);
} else {
/* look up in args */
obj = PySequence_GetItem(args, index);