[xmlsec] xmlSecPtrListEnsureSize failing
Aleksey Sanin
aleksey at aleksey.com
Thu Jan 22 10:29:09 PST 2004
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
More information about the xmlsec
mailing list