mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
res_geolocation: Fix segfault when there's an empty element
Fixed a segfault caused by var_list_from_loc_info() encountering an empty location info element. Fixed an issue in ast_strsep() where a value with only whitespace wasn't being preserved. Fixed an issue in ast_variable_list_from_quoted_string() where an empty value was considered a failure. ASTERISK-30215 Reported by: Dan Cropp Change-Id: Ieca64e061a6d9298f0196c694b60d986ef82613a
This commit is contained in:
@@ -646,15 +646,16 @@ struct ast_variable *ast_variable_list_sort(struct ast_variable *start)
|
||||
struct ast_variable *ast_variable_list_append_hint(struct ast_variable **head, struct ast_variable *search_hint, struct ast_variable *newvar)
|
||||
{
|
||||
struct ast_variable *curr;
|
||||
struct ast_variable *sh = search_hint;
|
||||
ast_assert(head != NULL);
|
||||
|
||||
if (!*head) {
|
||||
*head = newvar;
|
||||
} else {
|
||||
if (search_hint == NULL) {
|
||||
search_hint = *head;
|
||||
if (sh == NULL) {
|
||||
sh = *head;
|
||||
}
|
||||
for (curr = search_hint; curr->next; curr = curr->next);
|
||||
for (curr = sh; curr->next; curr = curr->next);
|
||||
curr->next = newvar;
|
||||
}
|
||||
|
||||
@@ -752,12 +753,8 @@ struct ast_variable *ast_variable_list_from_quoted_string(const char *input, con
|
||||
}
|
||||
|
||||
item_value = ast_strsep_quoted(&item, nv_sep, quote, AST_STRSEP_ALL);
|
||||
if (!item_value) {
|
||||
ast_variables_destroy(new_list);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_var = ast_variable_new(item_name, item_value, "");
|
||||
new_var = ast_variable_new(item_name, item_value ?: "", "");
|
||||
if (!new_var) {
|
||||
ast_variables_destroy(new_list);
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user