Skip to content

Commit 392ac3a

Browse files
committed
Fixed runtime crash
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
1 parent 8301594 commit 392ac3a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/expand.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ void ExpandAddress(const Nan::FunctionCallbackInfo<v8::Value>& info) {
120120
for (i = 0; i < num_expansions; i++) {
121121
v8::Local<v8::String> e = Nan::New(expansions[i]).ToLocalChecked();
122122
ret->Set(context, i, e);
123-
free(expansions[i]);
124123
}
125-
free(expansions);
124+
125+
// Free expansions
126+
libpostal_expansion_array_destroy(expansions, num_expansions);
126127

127128
info.GetReturnValue().Set(ret);
128129
}

0 commit comments

Comments
 (0)