提交 43beb82e 编写于 作者: J Jim Meyering

linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test

* tests/nodeinfotest.c (linuxTestCompareFiles): Don't use
nodeinfo->member uninitialized.  linuxNodeInfoCPUPopulate requires
that some of its nodeinfo members (including threads) be initialized
upon input.  The nodeinfotest.c program lacked the initialization,
while the only other use (nodeGetInfo) did perform it.
It's not trivial to move the initialization into the function,
since nodeGetInfo sets at least one member after clearing the
buffer but before calling linuxNodeInfoCPUPopulate.
上级 4d2adaa1
......@@ -40,6 +40,8 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
cpuinfo = fopen(cpuinfofile, "r");
if (!cpuinfo)
return -1;
memset(&nodeinfo, 0, sizeof(nodeinfo));
if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) {
fclose(cpuinfo);
return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册