Subject: Re: regcomp() overwrites random memory
To: None <current-users@NetBSD.ORG>
From: Peter Simons <>
List: current-users
Date: 01/06/1997 04:06:25
I just wanted to let you know that I was able to track the problem
down and indeed it was a bug in my own code and not in the excellent
regular expression matching routines. False alarm. :)

I allocated a buffer -one- damn byte too small, because I forgot to
count the terminating \0 byte in, when calculating the length of the
string, the buffer was supposed to hold.

Oh well... it cost me only about 48 hours of debugging and reading
weird source codes, so I guess it was worth it. I learned a lesson:
Always add "#define mymalloc(x) malloc((x)+1)" to your code first of
all. :-)

BTW, I would never have found the bug weren't it for the really,
really, excellent dmalloc package by Gray Watson. Anybody who wonders
whether his routines leak memory or overwrite the buffer limits should
really take a look at -- the package
is really powerful.

	bye, Peter