curl-library
RE: Allocated curl_easy_setopt() strings
From: Patrick Monnerat <Patrick.Monnerat_at_datasphere.ch>
Date: Tue, 31 Jul 2007 11:33:31 +0200
Date: Tue, 31 Jul 2007 11:33:31 +0200
Great. But I do not agree with your Curl_dupset code. You should do it
in 2 loop passes, in case of memory allocation error. Like:
for(i=0; i< STRING_LAST; i++)
dst->set.str[i]=NULL; /* we clear it first, since it was set to the
wrong
pointer above */
for(i=0; i< STRING_LAST; i++) {
r = Curl_setstropt(&dst->set.str[i], src->set.str[i]);
if (r != CURLE_OK)
break;
}
This way, if an allocation error occurs in Curl_setstropt(), the
procedure leaves pointers at str[i+1] and nexts with a null value, so
releasing the destination set will not deallocate the source strings...
Received on 2007-07-31