提交 6b20f406 编写于 作者: J Joo Aun Saw 提交者: Jonathan Cameron

tools: iio: Set caller's ci_array pointer to NULL after free

On error, caller's ci_array is freed and set to NULL to avoid
potential double free if some other user of this code is not
sufficiently careful. Counter is reset to zero for consistency.
Signed-off-by: NJoo Aun Saw <jasaw@dius.com.au>
Signed-off-by: NJonathan Cameron <jic23@kernel.org>
上级 bdb25b0a
......@@ -526,6 +526,8 @@ int build_channel_array(const char *device_dir,
free((*ci_array)[i].generic_name);
}
free(*ci_array);
*ci_array = NULL;
*counter = 0;
error_close_dir:
if (dp)
if (closedir(dp) == -1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册