Only create parser response when it is used
Previously, an unused response would not be freed, causing a leak.
This commit is contained in:
@@ -1755,8 +1755,6 @@ libpostal_address_parser_response_t *address_parser_parse(char *address, char *l
|
||||
label = strdup(ADDRESS_PARSER_LABEL_POSTAL_CODE);
|
||||
}
|
||||
|
||||
response = address_parser_response_new();
|
||||
|
||||
// Implicit: if most_common is not one of the above, ignore and parse regularly
|
||||
if (label != NULL) {
|
||||
char **single_label = malloc(sizeof(char *));
|
||||
@@ -1764,6 +1762,8 @@ libpostal_address_parser_response_t *address_parser_parse(char *address, char *l
|
||||
char **single_component = malloc(sizeof(char *));
|
||||
single_component[0] = strdup(normalized);
|
||||
|
||||
response = address_parser_response_new();
|
||||
|
||||
response->num_components = 1;
|
||||
response->labels = single_label;
|
||||
response->components = single_component;
|
||||
|
||||
Reference in New Issue
Block a user