Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: memory leak in anonoymous functions



On Dec 3, 11:20pm, Peter Stephenson wrote:
}
} 		save = (!(state->prog->flags & EF_HEAP) &&
} 			!strcmp(opat, right) && pprog != dummy_patprog2);
} 
} 		if (!(pprog = patcompile(right, (save ? PAT_ZDUP : PAT_STATIC),
} 					 NULL))) {
} 		    zwarnnam(fromtest, "bad pattern: %s", right);
} 		    return 2;
} 		}
} 		else if (save)
} 		    state->prog->pats[npat] = pprog;
} 
} That pprog might be leaked, it says.  Er, yeah, right.

Well, if save is false but patcompile() returns non-null, then pprog
is never assigned anywhere.  But if save is false then patcompile() was
called with PAT_STATIC and there's nothing to free.  It's not very
surprising that a compile-time analysis wouldn't figure that out, but
valgrind does runtime analysis ...

Which would mean that state->prog->pats[] is what's being leaked ...,
sometime after evalcond() returns?



Messages sorted by: Reverse Date, Date, Thread, Author