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

Re: [PATCH] db/gdbm rewrite



On Thu, Feb 16, 2017, at 08:03 AM, Sebastian Gniazdowski wrote:
> On Thu, Feb 16, 2017, at 07:11 AM, Peter Stephenson wrote:
> > % zmodload zsh/db/gdbm
> > % ztie -d db/gdbm -f db.gdbm dbase
> > % dbase[testkey]=somewhat
> > ==25034== Invalid write of size 1
> > ==25034==    at 0x80E0B78: metafy (utils.c:4652)
> 
> I've used HEAP_ALLOC instead of HEAP_DUP in argument for metafy. Fixing
> this resolves valgrind report. Important catch.. Hopefully it will
> resolve enable-zsh-mem problem (I cannot reproduce that). Sending as
> complete patch plus db_gdbm.c file.

Yeah this will fix the problem. I did:

        pm->u.str = metafy(content.dptr, content.dsize, META_ALLOC);

There were no meta characters so metafy() didn't allocate memory,
returned internal GDBM  pointer. META_DUP always allocates. Thanks!

-- 
Sebastian Gniazdowski
psprint2@xxxxxxxxxxxx



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