zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] don't call regfree() on uninitialized regex_t
@ 2009-01-19  8:22 Wayne Davison
  2009-01-19 21:35 ` Phil Pennock
  0 siblings, 1 reply; 2+ messages in thread
From: Wayne Davison @ 2009-01-19  8:22 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 235 bytes --]

While I was fixing a few compiler warnings in zcond_regex_match(), I
noticed that regfree() could be called on an uninitialized regex_t if
the "id" value passed in to the function was invalid.  Attached is one
possible fix.

..wayne..

[-- Attachment #2: regex.patch --]
[-- Type: text/x-diff, Size: 312 bytes --]

--- Src/Modules/regex.c	19 Jan 2009 08:00:15 -0000	1.4
+++ Src/Modules/regex.c	19 Jan 2009 08:14:25 -0000
@@ -120,7 +120,7 @@ zcond_regex_match(char **a, int id)
 	break;
     default:
 	DPUTS(1, "bad regex option");
-	break;
+	return 0; /* nothing to cleanup, especially not "re". */
     }
 
     if (matches)

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] don't call regfree() on uninitialized regex_t
  2009-01-19  8:22 [PATCH] don't call regfree() on uninitialized regex_t Wayne Davison
@ 2009-01-19 21:35 ` Phil Pennock
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Pennock @ 2009-01-19 21:35 UTC (permalink / raw)
  To: Wayne Davison; +Cc: zsh-workers

On 2009-01-19 at 00:22 -0800, Wayne Davison wrote:
> While I was fixing a few compiler warnings in zcond_regex_match(), I
> noticed that regfree() could be called on an uninitialized regex_t if
> the "id" value passed in to the function was invalid.  Attached is one
> possible fix.

Thanks -- looks like I was too clever for my own good.

-Phil


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-19 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-19  8:22 [PATCH] don't call regfree() on uninitialized regex_t Wayne Davison
2009-01-19 21:35 ` Phil Pennock

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).