Skip to content

Commit

Permalink
Fixed runtime crash (#58)
Browse files Browse the repository at this point in the history
Instead of manually freeing the memory allocated by `libpostal_expand_address()`, use `libpostal_expansion_array_destroy()` to free the memory.

This is how example program from libpostal frees the memory.
For more details, please refer to this issue:
openvenues/libpostal#682
  • Loading branch information
aamirglb authored Jan 30, 2025
1 parent 8301594 commit c2bd952
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/expand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ void ExpandAddress(const Nan::FunctionCallbackInfo<v8::Value>& info) {
for (i = 0; i < num_expansions; i++) {
v8::Local<v8::String> e = Nan::New(expansions[i]).ToLocalChecked();
ret->Set(context, i, e);
free(expansions[i]);
}
free(expansions);

// Free expansions
libpostal_expansion_array_destroy(expansions, num_expansions);

info.GetReturnValue().Set(ret);
}
Expand Down

0 comments on commit c2bd952

Please sign in to comment.