Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sat, 20 Feb 2016 18:41:30 UTC Commit: a4e061b00c475be615e88411014032c0d6044a01 https://github.com/geany/geany-plugins/commit/a4e061b00c475be615e88411014032...
Log Message: ----------- pretty-printer: Fix memory leak on reallocation error
Modified Paths: -------------- pretty-printer/src/PrettyPrinter.c
Modified: pretty-printer/src/PrettyPrinter.c 7 lines changed, 6 insertions(+), 1 deletions(-) =================================================================== @@ -130,7 +130,12 @@ int processXMLPrettyPrinting(char** buffer, int* length, PrettyPrintingOptions*
/* adjust the final size */ reallocated = (char*)realloc(xmlPrettyPrinted, xmlPrettyPrintedIndex); - if (reallocated == NULL) { PP_ERROR("Allocation error (reallocation size is %d)", xmlPrettyPrintedIndex); return PRETTY_PRINTING_SYSTEM_ERROR; } + if (reallocated == NULL) { + PP_ERROR("Allocation error (reallocation size is %d)", xmlPrettyPrintedIndex); + free(xmlPrettyPrinted); + xmlPrettyPrinted = NULL; + return PRETTY_PRINTING_SYSTEM_ERROR; + } xmlPrettyPrinted = reallocated;
/* freeing the unused values */
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org