From: Victor Julien Date: Mon, 24 Oct 2022 10:48:28 +0000 (+0200) Subject: membuffer: errno style error reporting X-Git-Tag: suricata-7.0.0-rc1~234 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0efdab1f5a42ded07d32f71944bbbcabf98a3094;p=thirdparty%2Fsuricata.git membuffer: errno style error reporting --- diff --git a/src/util-buffer.c b/src/util-buffer.c index d4f50b06a4..4579d4a923 100644 --- a/src/util-buffer.c +++ b/src/util-buffer.c @@ -31,9 +31,13 @@ MemBuffer *MemBufferCreateNew(uint32_t size) { + sc_errno = SC_OK; if (size > MAX_LIMIT) { - SCLogWarning(SC_ERR_MEM_BUFFER_API, "Mem buffer asked to create " - "buffer with size greater than API limit - %d", MAX_LIMIT); + SCLogWarning(SC_EINVAL, + "Mem buffer asked to create " + "buffer with size greater than API limit - %d", + MAX_LIMIT); + sc_errno = SC_EINVAL; return NULL; } @@ -41,6 +45,7 @@ MemBuffer *MemBufferCreateNew(uint32_t size) MemBuffer *buffer = SCMalloc(total_size); if (unlikely(buffer == NULL)) { + sc_errno = SC_ENOMEM; return NULL; } memset(buffer, 0, total_size);