mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 11:53:00 -04:00
Merge remote branch 'origin/patches-2.0'
This commit is contained in:
commit
8b0afe96eb
4
evdns.c
4
evdns.c
@ -3071,6 +3071,10 @@ search_request_new(struct evdns_base *base, struct evdns_request *handle,
|
||||
}
|
||||
EVUTIL_ASSERT(handle->search_origname == NULL);
|
||||
handle->search_origname = mm_strdup(name);
|
||||
if (handle->search_origname == NULL) {
|
||||
/* XXX Should we dealloc req? If yes, how? */
|
||||
return NULL;
|
||||
}
|
||||
handle->search_state = base->global_search_state;
|
||||
handle->search_flags = flags;
|
||||
base->global_search_state->refcount++;
|
||||
|
7
evutil.c
7
evutil.c
@ -972,8 +972,13 @@ addrinfo_from_hostent(const struct hostent *ent,
|
||||
res = evutil_addrinfo_append(res, ai);
|
||||
}
|
||||
|
||||
if (res && ((hints->ai_flags & EVUTIL_AI_CANONNAME) && ent->h_name))
|
||||
if (res && ((hints->ai_flags & EVUTIL_AI_CANONNAME) && ent->h_name)) {
|
||||
res->ai_canonname = mm_strdup(ent->h_name);
|
||||
if (res->ai_canonname == NULL) {
|
||||
evutil_freeaddrinfo(res);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
50
http.c
50
http.c
@ -1111,7 +1111,7 @@ evhttp_connection_set_local_address(struct evhttp_connection *evcon,
|
||||
if (evcon->bind_address)
|
||||
mm_free(evcon->bind_address);
|
||||
if ((evcon->bind_address = mm_strdup(address)) == NULL)
|
||||
event_err(1, "%s: strdup", __func__);
|
||||
event_warn("%s: strdup", __func__);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2492,6 +2492,10 @@ evhttp_response_code(struct evhttp_request *req, int code, const char *reason)
|
||||
if (reason == NULL)
|
||||
reason = evhttp_response_phrase_internal(code);
|
||||
req->response_code_line = mm_strdup(reason);
|
||||
if (req->response_code_line == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
/* XXX what else can we do? */
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -3281,6 +3285,11 @@ evhttp_set_cb(struct evhttp *http, const char *uri,
|
||||
}
|
||||
|
||||
http_cb->what = mm_strdup(uri);
|
||||
if (http_cb->what == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
mm_free(http_cb);
|
||||
return (-3);
|
||||
}
|
||||
http_cb->cb = cb;
|
||||
http_cb->cbarg = cbarg;
|
||||
|
||||
@ -3912,6 +3921,10 @@ parse_authority(struct evhttp_uri *uri, char *s, char *eos)
|
||||
EVUTIL_ASSERT(eos);
|
||||
if (eos == s) {
|
||||
uri->host = mm_strdup("");
|
||||
if (uri->host == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3923,6 +3936,10 @@ parse_authority(struct evhttp_uri *uri, char *s, char *eos)
|
||||
return -1;
|
||||
*cp++ = '\0';
|
||||
uri->userinfo = mm_strdup(s);
|
||||
if (uri->userinfo == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
cp = s;
|
||||
}
|
||||
@ -3950,6 +3967,10 @@ parse_authority(struct evhttp_uri *uri, char *s, char *eos)
|
||||
return -1;
|
||||
}
|
||||
uri->host = mm_malloc(eos-cp+1);
|
||||
if (uri->host == NULL) {
|
||||
event_warn("%s: malloc", __func__);
|
||||
return -1;
|
||||
}
|
||||
memcpy(uri->host, cp, eos-cp);
|
||||
uri->host[eos-cp] = '\0';
|
||||
return 0;
|
||||
@ -4012,14 +4033,14 @@ evhttp_uri_parse(const char *source_uri)
|
||||
|
||||
struct evhttp_uri *uri = mm_calloc(1, sizeof(struct evhttp_uri));
|
||||
if (uri == NULL) {
|
||||
event_err(1, "%s: calloc", __func__);
|
||||
event_warn("%s: calloc", __func__);
|
||||
goto err;
|
||||
}
|
||||
uri->port = -1;
|
||||
|
||||
readbuf = mm_strdup(source_uri);
|
||||
if (readbuf == NULL) {
|
||||
event_err(1, "%s: strdup", __func__);
|
||||
event_warn("%s: strdup", __func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -4040,7 +4061,10 @@ evhttp_uri_parse(const char *source_uri)
|
||||
if (token && scheme_ok(readp,token)) {
|
||||
*token = '\0';
|
||||
uri->scheme = mm_strdup(readp);
|
||||
|
||||
if (uri->scheme == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
goto err;
|
||||
}
|
||||
readp = token+1; /* eat : */
|
||||
}
|
||||
|
||||
@ -4097,11 +4121,25 @@ evhttp_uri_parse(const char *source_uri)
|
||||
|
||||
EVUTIL_ASSERT(path);
|
||||
uri->path = mm_strdup(path);
|
||||
if (uri->path == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (query)
|
||||
if (query) {
|
||||
uri->query = mm_strdup(query);
|
||||
if (fragment)
|
||||
if (uri->query == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
if (fragment) {
|
||||
uri->fragment = mm_strdup(fragment);
|
||||
if (uri->fragment == NULL) {
|
||||
event_warn("%s: strdup", __func__);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
mm_free(readbuf);
|
||||
|
||||
|
36
select.c
36
select.c
@ -91,6 +91,7 @@ const struct eventop selectops = {
|
||||
};
|
||||
|
||||
static int select_resize(struct selectop *sop, int fdsz);
|
||||
static void select_free_selectop(struct selectop *sop);
|
||||
|
||||
static void *
|
||||
select_init(struct event_base *base)
|
||||
@ -100,7 +101,10 @@ select_init(struct event_base *base)
|
||||
if (!(sop = mm_calloc(1, sizeof(struct selectop))))
|
||||
return (NULL);
|
||||
|
||||
select_resize(sop, howmany(32 + 1, NFDBITS)*sizeof(fd_mask));
|
||||
if (select_resize(sop, howmany(32 + 1, NFDBITS)*sizeof(fd_mask))) {
|
||||
select_free_selectop(sop);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
evsig_init(base);
|
||||
|
||||
@ -129,11 +133,14 @@ select_dispatch(struct event_base *base, struct timeval *tv)
|
||||
size_t sz = sop->event_fdsz;
|
||||
if (!(readset_out = mm_realloc(sop->event_readset_out, sz)))
|
||||
return (-1);
|
||||
sop->event_readset_out = readset_out;
|
||||
if (!(writeset_out = mm_realloc(sop->event_writeset_out, sz))) {
|
||||
mm_free(readset_out);
|
||||
/* We don't free readset_out here, since it was
|
||||
* already successfully reallocated. The next time
|
||||
* we call select_dispatch, the realloc will be a
|
||||
* no-op. */
|
||||
return (-1);
|
||||
}
|
||||
sop->event_readset_out = readset_out;
|
||||
sop->event_writeset_out = writeset_out;
|
||||
sop->resize_out_sets = 0;
|
||||
}
|
||||
@ -186,7 +193,6 @@ select_dispatch(struct event_base *base, struct timeval *tv)
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
select_resize(struct selectop *sop, int fdsz)
|
||||
{
|
||||
@ -199,8 +205,15 @@ select_resize(struct selectop *sop, int fdsz)
|
||||
if ((readset_in = mm_realloc(sop->event_readset_in, fdsz)) == NULL)
|
||||
goto error;
|
||||
sop->event_readset_in = readset_in;
|
||||
if ((writeset_in = mm_realloc(sop->event_writeset_in, fdsz)) == NULL)
|
||||
if ((writeset_in = mm_realloc(sop->event_writeset_in, fdsz)) == NULL) {
|
||||
/* Note that this will leave event_readset_in expanded.
|
||||
* That's okay; we wouldn't want to free it, since that would
|
||||
* change the semantics of select_resize from "expand the
|
||||
* readset_in and writeset_in, or return -1" to "expand the
|
||||
* *set_in members, or trash them and return -1."
|
||||
*/
|
||||
goto error;
|
||||
}
|
||||
sop->event_writeset_in = writeset_in;
|
||||
sop->resize_out_sets = 1;
|
||||
|
||||
@ -293,11 +306,8 @@ select_del(struct event_base *base, int fd, short old, short events, void *p)
|
||||
}
|
||||
|
||||
static void
|
||||
select_dealloc(struct event_base *base)
|
||||
select_free_selectop(struct selectop *sop)
|
||||
{
|
||||
struct selectop *sop = base->evbase;
|
||||
|
||||
evsig_dealloc(base);
|
||||
if (sop->event_readset_in)
|
||||
mm_free(sop->event_readset_in);
|
||||
if (sop->event_writeset_in)
|
||||
@ -310,3 +320,11 @@ select_dealloc(struct event_base *base)
|
||||
memset(sop, 0, sizeof(struct selectop));
|
||||
mm_free(sop);
|
||||
}
|
||||
|
||||
static void
|
||||
select_dealloc(struct event_base *base)
|
||||
{
|
||||
evsig_dealloc(base);
|
||||
|
||||
select_free_selectop(base->evbase);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user