memory leak in KJS

George Staikos staikos at kde.org
Sat Jan 29 04:39:39 GMT 2005


On Friday 28 January 2005 21:19, Harri Porten wrote:
> On Fri, 28 Jan 2005, [utf-8] André Wöbbeking wrote:
> > x bytes in y blocks are definitely lost
> > operator new(unsigned) (vg_replace_malloc.c:133)
> > kjsyyparse() (grammar.y:172)
> > KJS::Parser::parse(KJS::UChar const*, unsigned, KJS::SourceCode**, int*,
> > KJS::UString*) (internal.cpp:485)
>
> There's one known leak in the parser that occurs when the parser hits a
> syntax error. In that case the bison generated will unwind and leave the
> memory allocated for string tokens without an owner. Last time I tried to
> solve it I realized how difficult it is to do with bison. Having a pool of
> strings allocated during parsing (that could be freed in the end if they
> are unused might be a possibility).

  I had this problem in Kst also.  I solved it by adding a ridiculous number 
of error paths into the syntax and cleaning up recursively in those cases.  
It's unfortunately messy, and for the few bytes it consumes, I guess it's 
probably not worth the effort in most cases.

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/




More information about the kde-core-devel mailing list