summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-06-15 22:25:48 +0200
committerLennart Poettering <lennart@poettering.net>2016-06-21 13:20:47 +0200
commit35ca4ce022aec65663baf9b4cf9f7f932e196237 (patch)
treea3fe8fd2a5b952d692248047aa2501e034fb9c3d /src
parentbe371fe03937b6b3c45ee58a96622ff1849b14e4 (diff)
string-table: make sure DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() handles NULL strings nicely
xyz_from_string() functions defined with DEFINE_STRING_TABLE_LOOKUP() properly handle NULL strings already. make sure the equivalent functions defined with DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() do the same.
Diffstat (limited to 'src')
-rw-r--r--src/basic/string-table.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/basic/string-table.h b/src/basic/string-table.h
index d88625fca7..369610efc8 100644
--- a/src/basic/string-table.h
+++ b/src/basic/string-table.h
@@ -48,6 +48,8 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k
#define _DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_WITH_BOOLEAN(name,type,yes,scope) \
scope type name##_from_string(const char *s) { \
int b; \
+ if (!s) \
+ return -1; \
b = parse_boolean(s); \
if (b == 0) \
return (type) 0; \