From 93397449d4051fe3f545660cc74aad38355dee55 Mon Sep 17 00:00:00 2001 From: Daniel Hirt Date: Mon, 16 Jul 2018 06:09:38 -0400 Subject: [PATCH] Eina binbuf: add explicit null-check before magic-check Summary: Using `--disable-magic-debug` defines EINA_MAGIC_CHECK to always evaluate to `1`. Eina_Binbuf's null-check relied solely on the EINA_MAGIC_CHECK, and failed to pick up on the cases where `buf` was passed as NULL. This has led to a segfault when a NULL `buf` was passed in the test suite (see referenced ticket). This fix adds an explicit NULL check. Fixes https://phab.enlightenment.org/T7147 Reviewers: zmike Reviewed By: zmike Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6592 --- src/lib/eina/eina_strbuf_common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/eina/eina_strbuf_common.h b/src/lib/eina/eina_strbuf_common.h index 931cae456d..447cb47a74 100644 --- a/src/lib/eina/eina_strbuf_common.h +++ b/src/lib/eina/eina_strbuf_common.h @@ -25,6 +25,7 @@ struct _Eina_Strbuf #define EINA_MAGIC_CHECK_STRBUF(d, ...) \ do { \ + if (!(d)) return __VA_ARGS__; \ if (!EINA_MAGIC_CHECK((d), _STRBUF_MAGIC)) \ { \ EINA_MAGIC_FAIL((d), _STRBUF_MAGIC); \