src/function.cpp: Fix possible NULL-dereference

UBSan complained, so let's check.
This commit is contained in:
Fabian Homborg 2019-01-31 16:01:12 +01:00
parent c7635ed2c0
commit 0770fd1f89

View File

@ -251,7 +251,10 @@ bool function_get_definition(const wcstring &name, wcstring &out_definition) {
scoped_rlock locker(functions_lock); scoped_rlock locker(functions_lock);
const function_info_t *func = function_get(name); const function_info_t *func = function_get(name);
if (func) { if (func) {
out_definition = func->props->body_node.get_source(func->props->parsed_source->src); auto props = func->props;
if (props && props->parsed_source) {
out_definition = props->body_node.get_source(props->parsed_source->src);
}
} }
return func != NULL; return func != NULL;
} }