]> granicus.if.org Git - curl/commitdiff
easy_events: make event data static
authorDaniel Stenberg <daniel@haxx.se>
Sun, 6 Aug 2017 21:42:50 +0000 (23:42 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 6 Aug 2017 21:42:50 +0000 (23:42 +0200)
First: this function is only used in debug-builds and not in
release/real builds. It is used to drive tests using the event-based
API.

A pointer to the local struct is passed to CURLMOPT_TIMERDATA, but the
CURLMOPT_TIMERFUNCTION calback can in fact be called even after this
funtion returns, namely when curl_multi_remove_handle() is called.

Reported-by: Brian Carpenter
lib/easy.c

index 33ae90fd5d8a944471f2f6ba72ff694504d51f40..66ec38a5eea80735a68f788521dd2b840c47649f 100644 (file)
@@ -653,7 +653,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
  */
 static CURLcode easy_events(struct Curl_multi *multi)
 {
-  struct events evs= {2, FALSE, 0, NULL, 0};
+  /* this struct is made static to allow it to be used after this function
+     returns and curl_multi_remove_handle() is called */
+  static struct events evs= {2, FALSE, 0, NULL, 0};
 
   /* if running event-based, do some further multi inits */
   events_setup(multi, &evs);