core: check that string is not NULL in function string_strndup