From a9f1c29a36e1a98c04a9cfc04b0a38aaef48bc9e Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Wed, 16 Jun 2021 22:32:25 +0800 Subject: Handler gets used only if it's not NULL --- request.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/request.h b/request.h index 756edd7..7960561 100644 --- a/request.h +++ b/request.h @@ -107,7 +107,8 @@ static inline void request(void (*handler)(icclient_fetch_t *), void *callback, va_end(ap); #ifdef __EMSCRIPTEN__ - attr.onsuccess = handler; + if (handler) + attr.onsuccess = handler; attr.userData = callback; strcpy(attr.requestMethod, "GET"); emscripten_fetch(&attr, url); @@ -134,7 +135,7 @@ static inline void request(void (*handler)(icclient_fetch_t *), void *callback, CURLcode res = curl_easy_perform(curl); if (post) curl_formfree(post); - if (res == CURLE_OK) + if (res == CURLE_OK && handler) handler(&fetch); #ifdef DEBUG else { -- cgit v1.3