summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochem Broekhoff <jochembroekhoff@users.noreply.github.com>2021-04-09 11:03:30 +0200
committerDaniel Stenberg <daniel@haxx.se>2021-04-09 11:44:21 +0200
commit255bdfe65c593c5c484fe5e8606f1915c26097e3 (patch)
tree02c7254245543f6184bc6ccbfec70fc4f002f41f
parent9c1e1a6105f34ffe3b5a16e874a92c9558ddbd96 (diff)
downloadcurl-255bdfe65c593c5c484fe5e8606f1915c26097e3.tar.gz
examples/hiperfifo.c: check event_initialized before delete
If event_del is called with the event struct (still) zeroed out, a segmentation fault may occur. event_initialized checks whether the event struct is nonzero. Closes #6876
-rw-r--r--docs/examples/hiperfifo.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/docs/examples/hiperfifo.c b/docs/examples/hiperfifo.c
index 2ca625183..b22f1a71c 100644
--- a/docs/examples/hiperfifo.c
+++ b/docs/examples/hiperfifo.c
@@ -234,7 +234,9 @@ static void timer_cb(int fd, short kind, void *userp)
static void remsock(SockInfo *f)
{
if(f) {
- event_del(&f->ev);
+ if(event_initialized(&f->ev)) {
+ event_del(&f->ev);
+ }
free(f);
}
}
@@ -252,7 +254,9 @@ static void setsock(SockInfo *f, curl_socket_t s, CURL *e, int act,
f->sockfd = s;
f->action = act;
f->easy = e;
- event_del(&f->ev);
+ if(event_initialized(&f->ev)) {
+ event_del(&f->ev);
+ }
event_assign(&f->ev, g->evbase, f->sockfd, kind, event_cb, g);
event_add(&f->ev, NULL);
}