zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: memory leak found by coverity
@ 2018-04-05 14:46 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2018-04-05 14:46 UTC (permalink / raw)
  To: Zsh workers

Coverity also identifies a memory leak in the case of these two error
messages. This is new code since the last release.

Oliver

diff --git a/Src/params.c b/Src/params.c
index de7730ae7..36f5f0676 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3216,7 +3216,7 @@ assignaparam(char *s, char **val, int flags)
      * This only applies if the flag ASSPM_KEY_VALUE is passed in,
      * indicating prefork() detected this syntax.
      *
-     * For associative arrays we just junk the Makrer elements.
+     * For associative arrays we just junk the Marker elements.
      */
     if (flags & ASSPM_KEY_VALUE) {
 	char **aptr;
@@ -3243,6 +3243,7 @@ assignaparam(char *s, char **val, int flags)
 			(!isset(KSHARRAYS) && *iptr == 0)) {
 			unqueue_signals();
 			zerr("bad subscript for direct array assignment: %s", *aptr);
+			freearray(val);
 			return NULL;
 		    }
 		    if (!isset(KSHARRAYS))
@@ -3260,6 +3261,7 @@ assignaparam(char *s, char **val, int flags)
 	    fullval = zshcalloc((maxlen+1) * sizeof(char *));
 	    if (!fullval) {
 		zerr("array too large");
+		freearray(val);
 		return NULL;
 	    }
 	    fullval[maxlen] = NULL;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-05 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-05 14:46 PATCH: memory leak found by coverity Oliver Kiddle

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).