Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 943f339

Browse files
committed
Issue #3369: fix memory leak in floatobject.c. Thanks Kristján Jónsson
for the report and fix.
1 parent a05ada3 commit 943f339

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Objects/floatobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,19 @@ PyFloat_FromString(PyObject *v)
223223
p++;
224224
}
225225
if (PyOS_strnicmp(p, "inf", 4) == 0) {
226+
if (s_buffer != NULL)
227+
PyMem_FREE(s_buffer);
226228
Py_RETURN_INF(sign);
227229
}
228230
if (PyOS_strnicmp(p, "infinity", 9) == 0) {
231+
if (s_buffer != NULL)
232+
PyMem_FREE(s_buffer);
229233
Py_RETURN_INF(sign);
230234
}
231235
#ifdef Py_NAN
232236
if(PyOS_strnicmp(p, "nan", 4) == 0) {
237+
if (s_buffer != NULL)
238+
PyMem_FREE(s_buffer);
233239
Py_RETURN_NAN;
234240
}
235241
#endif

0 commit comments

Comments
 (0)