mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 19:21:53 +03:00
basic/string-table: avoid crash when table is sparse
Generated _from_string() would crash when invoked on a table with some holes.
This commit is contained in:
parent
1ad448673e
commit
aa73f181e9
@ -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; \
|
||||
|
Loading…
Reference in New Issue
Block a user