diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2023-02-22 12:16:47 +0000 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2023-02-22 14:40:24 +0000 |
commit | f36bb2f9f5b518d1ba23370f6e17c27a62489142 (patch) | |
tree | 378c4ece0f4305ea7d2bba14081db723276e5d27 /base | |
parent | c1d0170b2fad8386a9e41da27e6c7f422ed4fd3c (diff) | |
download | ghostpdl-f36bb2f9f5b518d1ba23370f6e17c27a62489142.tar.gz |
Fix memory leak seen in apitest using gpdl.
A C parameter list leaks when used in gpdl. Presumably this is
not seen in gs operation because of garbage collection.
We already have a function to allocate a C parameter list
(gs_c_param_list_alloc). We've always been releasing this
(gs_c_param_list_release), but that just releases the contents
not the list itself. Add a new function (gs_c_param_list_free)
that both releases and frees, and call this as appropriate.
Diffstat (limited to 'base')
-rw-r--r-- | base/gscparam.c | 10 | ||||
-rw-r--r-- | base/gsparam.h | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/base/gscparam.c b/base/gscparam.c index b39344172..1581ac537 100644 --- a/base/gscparam.c +++ b/base/gscparam.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2023 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -128,6 +128,14 @@ gs_c_param_list_alloc(gs_memory_t *mem, client_name_t cname) return gs_alloc_struct(mem, gs_c_param_list, &st_c_param_list, cname); } +void gs_c_param_list_free(gs_memory_t *mem, gs_c_param_list *plist, client_name_t cname) +{ + if (plist == NULL) + return; + gs_c_param_list_release(plist); + gs_free_object(mem, plist, cname); +} + static gs_c_param * c_param_find(const gs_c_param_list *plist, gs_param_name pkey, bool any) { diff --git a/base/gsparam.h b/base/gsparam.h index df3b1c03d..01b070f22 100644 --- a/base/gsparam.h +++ b/base/gsparam.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2021 Artifex Software, Inc. +/* Copyright (C) 2001-2023 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -570,6 +570,7 @@ void gs_c_param_list_write(gs_c_param_list *, gs_memory_t *); void gs_c_param_list_write_more(gs_c_param_list *); /* switch back to writing, no init */ void gs_c_param_list_read(gs_c_param_list *); /* switch to reading */ void gs_c_param_list_release(gs_c_param_list *); +void gs_c_param_list_free(gs_memory_t *, gs_c_param_list *, client_name_t); /* Given a string to parse (a list of key/value pairs), parse it and add * what we find to the supplied param list. Note that p is corrupted |