[geany/geany-plugins] a4e061: pretty-printer: Fix memory leak on reallocation error
Colomban Wendling
git-noreply at xxxxx
Thu Jun 9 13:09:14 UTC 2016
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Sat, 20 Feb 2016 18:41:30 UTC
Commit: a4e061b00c475be615e88411014032c0d6044a01
https://github.com/geany/geany-plugins/commit/a4e061b00c475be615e88411014032c0d6044a01
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).
More information about the Plugins-Commits
mailing list