From: Florian Forster Date: Wed, 3 Aug 2016 19:35:36 +0000 (+0200) Subject: write_http plugin: Be extra conservative in wh_reset_buffer(). X-Git-Tag: collectd-5.6.0~118 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=cd2238b8b4f4ecd80c45862b5aeed3d3d73eddfe write_http plugin: Be extra conservative in wh_reset_buffer(). This function is called from wh_callback_free() which is used to clean up after ?alloc() failures, so the "send_buffer" field may actually be NULL. Issue: #1835 --- diff --git a/src/write_http.c b/src/write_http.c index 3d50be53..ec538b61 100644 --- a/src/write_http.c +++ b/src/write_http.c @@ -95,6 +95,9 @@ static void wh_log_http_error (wh_callback_t *cb) static void wh_reset_buffer (wh_callback_t *cb) /* {{{ */ { + if ((cb == NULL) || (cb->send_buffer == NULL)) + return; + memset (cb->send_buffer, 0, cb->send_buffer_size); cb->send_buffer_free = cb->send_buffer_size; cb->send_buffer_fill = 0; @@ -320,7 +323,8 @@ static void wh_callback_free (void *data) /* {{{ */ cb = data; - wh_flush_nolock (/* timeout = */ 0, cb); + if (cb->send_buffer != NULL) + wh_flush_nolock (/* timeout = */ 0, cb); if (cb->curl != NULL) {