Skip to content

Commit 26c5c80

Browse files
committed
check if normalized string was allocated
1 parent 5669466 commit 26c5c80

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

importer/src/main.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -691,17 +691,20 @@ void normalize_libpostal(sqlite3pp::database& db, std::string address_expansion_
691691
// insert normalized, but not expanded string
692692
{
693693
char *normalized = libpostal_normalize_string(charbuff.data(), LIBPOSTAL_NORMALIZE_DEFAULT_STRING_OPTIONS);
694-
sqlite3pp::command cmd(db, "INSERT INTO normalized_name (prim_id, name) VALUES (?,?)");
695-
std::string s = normalized;
696-
cmd.binder() << d.id
697-
<< s;
698-
if (cmd.execute() != SQLITE_OK)
694+
if (normalized != NULL)
699695
{
700-
// std::cerr << "Error inserting: " << d.id << " " << s << std::endl;
701-
num_doubles_dropped++;
696+
sqlite3pp::command cmd(db, "INSERT INTO normalized_name (prim_id, name) VALUES (?,?)");
697+
std::string s = normalized;
698+
cmd.binder() << d.id
699+
<< s;
700+
if (cmd.execute() != SQLITE_OK)
701+
{
702+
// std::cerr << "Error inserting: " << d.id << " " << s << std::endl;
703+
num_doubles_dropped++;
704+
}
705+
706+
free(normalized);
702707
}
703-
704-
free(normalized);
705708
}
706709

707710
char **expansions = libpostal_expand_address(charbuff.data(), options, &num_expansions);

0 commit comments

Comments
 (0)