ghostscript/Bug-697545-Prevent-memory-leak-in-gx-path-assign-free.patch
2020-09-03 15:54:45 +08:00

45 lines
1.3 KiB
Diff

From efd0b47fe66a99097e200d76be1a4846ae2ef692 Mon Sep 17 00:00:00 2001
From: Shailesh Mistry <shailesh.mistry@hotmail.co.uk>
Date: Wed, 6 May 2020 18:01:07 +0100
Subject: [PATCH] Bug 697545 : Prevent memory leak in gx_path_assign_free.
Prevent memory leak by freeing path on all errors.
Error created using :-
MEMENTO_FAILAT=16246 ./membin/gpcl6 -sDEVICE=pbmraw -o /dev/null ./tests_private/pcl/pcl5cfts/fts.2120
---
base/gxpath.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/base/gxpath.c b/base/gxpath.c
index 4593d67..ffdea76 100644
--- a/base/gxpath.c
+++ b/base/gxpath.c
@@ -323,6 +323,7 @@ gx_path_assign_preserve(gx_path * ppto, gx_path * ppfrom)
int
gx_path_assign_free(gx_path * ppto, gx_path * ppfrom)
{
+ int code = 0;
/*
* Detect the special case where both paths have non-shared local
* segments, since we can avoid allocating new segments in this case.
@@ -349,13 +350,10 @@ gx_path_assign_free(gx_path * ppto, gx_path * ppfrom)
#undef tosegs
} else {
/* In all other cases, just do assign + free. */
- int code = gx_path_assign_preserve(ppto, ppfrom);
-
- if (code < 0)
- return code;
+ code = gx_path_assign_preserve(ppto, ppfrom);
}
gx_path_free(ppfrom, "gx_path_assign_free");
- return 0;
+ return code;
}
/*
--
1.8.3.1