summaryrefslogtreecommitdiffstats
path: root/src/basic/string-table.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-02-27 21:28:54 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-02-27 21:36:58 +0100
commitaa73f181e92ce991cff4e6890822764698befc90 (patch)
treeee58a708df251daf94837ff1c53224154f189ac1 /src/basic/string-table.h
parentman/systemd.unit: Add missing article to `Wants=` description (diff)
downloadsystemd-aa73f181e92ce991cff4e6890822764698befc90.tar.xz
systemd-aa73f181e92ce991cff4e6890822764698befc90.zip
basic/string-table: avoid crash when table is sparse
Generated _from_string() would crash when invoked on a table with some holes.
Diffstat (limited to 'src/basic/string-table.h')
-rw-r--r--src/basic/string-table.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/basic/string-table.h b/src/basic/string-table.h
index 2d3cf81435..96924778f5 100644
--- a/src/basic/string-table.h
+++ b/src/basic/string-table.h
@@ -44,7 +44,7 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
char *s; \
if (i < 0 || i > max) \
return -ERANGE; \
- if (i < (type) ELEMENTSOF(name##_table)) { \
+ if (i < (type) ELEMENTSOF(name##_table) && name##_table[i]) { \
s = strdup(name##_table[i]); \
if (!s) \
return -ENOMEM; \