config-parser: use zalloc()
While the code looks fine, clang 7 memory sanitizer complains about things like: ==26052==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7f4f4d003327 in weston_config_get_section /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:141:2 #1 0x7f4f4cfce11a in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3266:12 ==26683==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7f09ebd638e2 in config_section_get_entry /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:125:2 #1 0x7f09ebd661c4 in weston_config_section_get_bool /home/pq/build/weston-clang/../../git/weston/shared/config-parser.c:310:10 #2 0x7f09ebd2e1e5 in wet_main /home/pq/build/weston-clang/../../git/weston/compositor/main.c:3269:3 In all cases, the errors point to wl_list_for_each(). Making these allocations use zalloc() avoids these errors. Since using zalloc() is a good habit in any case, I didn't dig deeper. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
parent
94bf0a6463
commit
49399806a0
@ -39,6 +39,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <wayland-util.h>
|
||||
#include <libweston/zalloc.h>
|
||||
#include <libweston/config-parser.h>
|
||||
#include "helpers.h"
|
||||
#include "string-helpers.h"
|
||||
@ -344,7 +345,7 @@ config_add_section(struct weston_config *config, const char *name)
|
||||
{
|
||||
struct weston_config_section *section;
|
||||
|
||||
section = malloc(sizeof *section);
|
||||
section = zalloc(sizeof *section);
|
||||
if (section == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -366,7 +367,7 @@ section_add_entry(struct weston_config_section *section,
|
||||
{
|
||||
struct weston_config_entry *entry;
|
||||
|
||||
entry = malloc(sizeof *entry);
|
||||
entry = zalloc(sizeof *entry);
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -399,7 +400,7 @@ weston_config_parse(const char *name)
|
||||
struct weston_config_section *section = NULL;
|
||||
int i, fd;
|
||||
|
||||
config = malloc(sizeof *config);
|
||||
config = zalloc(sizeof *config);
|
||||
if (config == NULL)
|
||||
return NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user