diff options
author | Daniel Mack <github@zonque.org> | 2015-07-28 13:32:09 +0200 |
---|---|---|
committer | Daniel Mack <github@zonque.org> | 2015-07-28 13:32:09 +0200 |
commit | 87b46c575a14c133fbc408b56b0835f13a918b1d (patch) | |
tree | 9aa29502bc88f80cdf297d3e51f8b76fa2b5f1b0 /src | |
parent | 7ad6da648a8e3987ccc0931222de033307aaf437 (diff) | |
parent | 8cacf69b1b0dda4ad86c06dbba57f375865ccb6f (diff) |
Merge pull request #756 from ldzhong/fix
udev: avoid coredump when initializing udev builtins
Diffstat (limited to 'src')
-rw-r--r-- | src/udev/udev-builtin.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index fabc653800..88d1acf168 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -52,7 +52,7 @@ void udev_builtin_init(struct udev *udev) { return; for (i = 0; i < ELEMENTSOF(builtins); i++) - if (builtins[i]->init) + if (builtins[i] && builtins[i]->init) builtins[i]->init(udev); initialized = true; @@ -65,7 +65,7 @@ void udev_builtin_exit(struct udev *udev) { return; for (i = 0; i < ELEMENTSOF(builtins); i++) - if (builtins[i]->exit) + if (builtins[i] && builtins[i]->exit) builtins[i]->exit(udev); initialized = false; @@ -75,7 +75,7 @@ bool udev_builtin_validate(struct udev *udev) { unsigned int i; for (i = 0; i < ELEMENTSOF(builtins); i++) - if (builtins[i]->validate && builtins[i]->validate(udev)) + if (builtins[i] && builtins[i]->validate && builtins[i]->validate(udev)) return true; return false; } @@ -84,7 +84,8 @@ void udev_builtin_list(struct udev *udev) { unsigned int i; for (i = 0; i < ELEMENTSOF(builtins); i++) - fprintf(stderr, " %-14s %s\n", builtins[i]->name, builtins[i]->help); + if (builtins[i]) + fprintf(stderr, " %-14s %s\n", builtins[i]->name, builtins[i]->help); } const char *udev_builtin_name(enum udev_builtin_cmd cmd) { @@ -105,7 +106,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command) { if (pos) pos[0] = '\0'; for (i = 0; i < ELEMENTSOF(builtins); i++) - if (streq(builtins[i]->name, name)) + if (builtins[i] && streq(builtins[i]->name, name)) return i; return UDEV_BUILTIN_MAX; } |