[waffle] [PATCH] core: Zero-initialize wcore_info struct.

Paul Berry stereotype441 at gmail.com
Tue Aug 20 08:55:19 PDT 2013


Without this, it's possible that the garbage memory returned by malloc
will have wcore_info::is_init == true, causing wcore_tinfo_init() to
skip initialization.  That in turn causes a likely segfault the first
time wcore_info::error is accessed.

Fixes piglit crashes introduced by commit 6fcbe52 ("cmake: Refactor
compiler flags into new module").
---

Note: I'm not exactly sure why the piglit crashes only started
occurring with 6fcbe52.  My best guess is that the non-TLS code path
has always had this bug, and the cmake refactor caused me to switch
from building with TLS to building without TLS.

If that's the case then it may be worth fixing as well :)

 src/waffle/core/wcore_tinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/waffle/core/wcore_tinfo.c b/src/waffle/core/wcore_tinfo.c
index 4184b52..43f6e61 100644
--- a/src/waffle/core/wcore_tinfo.c
+++ b/src/waffle/core/wcore_tinfo.c
@@ -138,7 +138,7 @@ wcore_tinfo_get(void)
     if (tinfo)
         return tinfo;
 
-    tinfo = malloc(sizeof(*tinfo));
+    tinfo = calloc(1, sizeof(*tinfo));
     if (!tinfo)
         wcore_tinfo_abort_init();
 
-- 
1.8.3.4



More information about the waffle mailing list