- From: Mark Boudreaux <mboudreaux@citadel.com>
- Date: Wed, 19 Feb 2003 10:27:14 -0600
- To: <www-lib@w3.org>
- Message-ID: <714EB841B8E8024D91E725F6E3F5F7390B04FA@citadelex.corporate>
In the function HTRequest_setOutputStream...
/*
** Output stream
*/
PUBLIC void HTRequest_setOutputStream (HTRequest * me, HTStream *output)
{
if (me) {
if (output) {
me->output_stream = HTNoFreeStream_new(output);
me->orig_output_stream = output;
} else {
me->output_stream = output;
}
}
}
Should the second line be changed from
if (output) {
to
if (!output) {
If the output pointer is not NULL the current design reallocate it. If
it is NULL it will set me->output_stream to NULL.
With the current implementation, HTPostFormAnchorToChunk has a memory
leak...
/*
** POST a URL and save the response in a mem buffer
** ------------------------------------------------
** Returns chunk if OK - else NULL
*/
PUBLIC HTChunk * HTPostFormAnchorToChunk (HTAssocList * formdata,
HTAnchor * anchor,
HTRequest * request)
{
if (formdata && anchor && request) {
HTChunk * chunk = NULL;
HTStream * target = HTStreamToChunk(request, &chunk, 0);
HTRequest_setOutputStream(request, target);
if (HTPostFormAnchor(formdata, anchor, request) != NULL)
return chunk;
else {
HTChunk_delete(chunk);
return NULL;
}
}
return NULL;
}
target is allocated memory by HTStreamToChunk but then it is allocated
memory a second time with HTRequest_setOutputStream.
I may be off base here but from the way I read the code
HTRequest_setOutputStream should be changed.
Feedback, corrections, comments?
Mark
Received on Wednesday, 19 February 2003 11:33:45 UTC