diff options
author | Olly Betts <olly@survex.com> | 2016-01-12 13:49:55 +1300 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2016-01-12 13:49:55 +1300 |
commit | 584b328239360bcb45ad76fd62c7d45968b0a22e (patch) | |
tree | c030586e55589a72506279418e474f708741f251 | |
parent | f910607e26392a97ddf67d85085492587b39e78e (diff) | |
download | swig-584b328239360bcb45ad76fd62c7d45968b0a22e.tar.gz |
Fix minor memory leak in Python module docstring handling
Noted in #582 by aurelj.
-rw-r--r-- | Source/Modules/python.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 4c83be53c..3ed784c05 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -797,12 +797,14 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("python", f_shadow); - if (mod_docstring && Len(mod_docstring)) { - const char *triple_double = "\"\"\""; - // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ - // reported by pep257: https://github.com/GreenSteam/pep257 - bool multi_line_ds = Strchr(mod_docstring, '\n') != 0; - Printv(f_shadow, triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n\n", NIL); + if (mod_docstring) { + if (Len(mod_docstring)) { + const char *triple_double = "\"\"\""; + // follow PEP257 rules: https://www.python.org/dev/peps/pep-0257/ + // reported by pep257: https://github.com/GreenSteam/pep257 + bool multi_line_ds = Strchr(mod_docstring, '\n') != 0; + Printv(f_shadow, triple_double, multi_line_ds ? "\n":"", mod_docstring, multi_line_ds ? "\n":"", triple_double, "\n\n", NIL); + } Delete(mod_docstring); mod_docstring = NULL; } |