pypostal icon indicating copy to clipboard operation
pypostal copied to clipboard

It seems there is a memory leak in pyexpand.c

Open onriv opened this issue 2 years ago • 0 comments

Using valgrind to test the python api expand_address, I got a report:

==231== 51,166 bytes in 1,945 blocks are definitely lost in loss record 149 of 150
==231==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
==231==    by 0x59EBB89: strdup (in /usr/lib64/libc-2.17.so)
==231==    by 0x87EBD72: PyObject_to_string (pyutils.c:59)
==231==    by 0x87EB7CF: py_expand (pyexpand.c:120)
==231==    by 0x2D2077: cfunction_call_varargs (call.c:755)
==231==    by 0x2D2077: PyCFunction_Call (call.c:786)
==231==    by 0x2D2077: do_call_core (ceval.c:4641)
==231==    by 0x2D2077: _PyEval_EvalFrameDefault (ceval.c:3191)
==231==    by 0x220E84: PyEval_EvalFrameEx (ceval.c:547)
==231==    by 0x220E84: _PyEval_EvalCodeWithName (ceval.c:3930)
==231==    by 0x240CD2: _PyFunction_FastCallKeywords (call.c:433)
==231==    by 0x2CB394: call_function (ceval.c:4616)
==231==    by 0x2CB394: _PyEval_EvalFrameDefault (ceval.c:3124)
==231==    by 0x220E84: PyEval_EvalFrameEx (ceval.c:547)
==231==    by 0x220E84: _PyEval_EvalCodeWithName (ceval.c:3930)
==231==    by 0x222272: PyEval_EvalCodeEx (ceval.c:3959)
==231==    by 0x222272: PyEval_EvalCode (ceval.c:524)
==231==    by 0x32FC81: run_mod (pythonrun.c:1037)
==231==    by 0x339E1D: PyRun_FileExFlags (pythonrun.c:990)

Checking the source of function py_expand in pyexpand.c, line 120, it seems memory owning by the variable input is not freed

onriv avatar Nov 07 '22 11:11 onriv