[xmlsec] xmlSecPtrListEnsureSize failing
Jesse Pelton
jsp at PKC.com
Thu Jan 22 10:43:17 PST 2004
Your recollection is right, but Daniel checked in a change last April that
makes xmlReallocLoc() return NULL if passed NULL. See
http://cvs.gnome.org/bonsai/cvsview2.cgi?diff_mode=context&whitespace_mode=s
how&file=xmlmemory.c&branch=&root=/cvs/gnome&subdir=gnome-xml&command=DIFF_F
RAMESET&rev1=1.39&rev2=1.40. CCing the libxml list so Daniel can comment.
> -----Original Message-----
> From: Aleksey Sanin [mailto:aleksey at aleksey.com]
> Sent: Thursday, January 22, 2004 1:29 PM
> To: Rob Richards
> Cc: xmlsec at aleksey.com
> Subject: Re: [xmlsec] xmlSecPtrListEnsureSize failing
>
>
> xmlRealloc() is realloc() eququivalent. And as far as I can remember,
> ANSI C realloc() MUST accept NULL pointer as first argument.
>
> Aleksey
>
>
> Rob Richards wrote on 1/22/2004, 10:00 AM:
> > > Sorry but I don't see this code. What I have is :
> > >
> > > if(newSize < gInitialSize) {
> > > newSize = gInitialSize;
> > > }
> > >
> > > newData = (xmlSecPtr*)xmlRealloc(list->data,
> sizeof(xmlSecPtr) *
> > newSize);
> >
> > That's the origional source. I modified it to the following
> which fixed the
> > problem for me:
> >
> > if(newSize < gInitialSize) {
> > newSize = gInitialSize;
> > }
> >
> > if (list->data) {
> > newData = (xmlSecPtr*)xmlRealloc(list->data,
> sizeof(xmlSecPtr) *
> > newSize);
> > } else {
> > newData = (xmlSecPtr*)xmlMalloc(sizeof(xmlSecPtr) * newSize);
> > }
> >
> > under the origional source, list->data when entering
> xmlRealloc was NULL, so
> > the xmlRealloc call would fail as it explcitly tests for
> NULL before doing
> > anything.
> >
> > > > Am I missing something that wouldnt require the above
> as I see the call
> > to
> > > > xmlFree(list->data) in xmlSecPtrListEmpty, but dont see
> where list->data
> > is
> > > > actually alloc'd.
> > >
> > > Few lines bellow:
> > >
> > > list->data = newData;
> > > list->max = newSize;
> >
> > newData was NULL when returned from xmlRealloc, list->data
> is just set to
> > NULL (which is what it currently is anyways).
> > After this it falls into the xmlSecError handler.
> list->data doesnt ever
> > seem to have been initialized anywhere and the origional
> source is expecting
> > it to not be pointing at a zero'd out memory block.
> >
> > Rob
> _______________________________________________
> xmlsec mailing list
> xmlsec at aleksey.com
> http://www.aleksey.com/mailman/listinfo/xmlsec
>
More information about the xmlsec
mailing list