[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] [PATCH] uri parsing helpers
I suggest either allocating the uri struct in memory or not calling
evhttp_uri_clear at the top of evhttp_uri_parse. When declaring the
uri variable inside a function, it will be uninitialized, so in order
to avoid a crash from evhttp_uri_clear, one has to memset the struct
to zero. So I suggest setting all members to zero in evhttp_uri_parse,
at the top, and if the user wants to reuse the uri variable, they can
call evhttp_uri_clear later on.
Example:
void foo() {
evhttp_uri uri;
evhttp_uri_parse("http://foo", &uri); // causes crash
}
void bar() {
evhttp_uri uri;
memset(&uri, 0, sizeof(uri));
evhttp_uri_parse("http://bar", &uri); // no crash
}
My suggestion:
evhttp_uri *uri = evhttp_uri_parse("http://baz");
// do stuff, then:
evhttp_uri_free(uri);
Also, the function could return int (0 for success, -1 for failure),
because not all uris can be parsed properly. There are a few return
cases in it, and those can return -1.
On Sun, Aug 1, 2010 at 12:51 AM, Pavel Plesov <pavel.plesov@xxxxxxxxx> wrote:
> On Thu, Jul 15, 2010 at 6:31 AM, Nick Mathewson <nickm@xxxxxxxxxxxxx> wrote:
>
>> Could you upload it to the sourceforge patch tracker at
>> https://sourceforge.net/tracker/?group_id=50884&atid=461324 ?
>> Libevent 2.0.x is currently in feature-freeze, so we won't be merging
>> new externally visible functions (except for severe circumstances)
>> until 2.1.x development forks off.
>>
>> Also, the official Libevent repo is not on github; it's the
>> sourceforge one at git clone
>> git://levent.git.sourceforge.net/gitroot/levent/levent .
>
> Just uploaded the updated patch as:
> https://sourceforge.net/tracker/?func=detail&aid=3037660&group_id=50884&atid=461324
>
>
> --
> Pavel Plesov
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users  Âin the body.
>
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.