Skip to content

Commit

Permalink
allocate array of string using malloc rather than new []
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoCaso committed Jan 11, 2022
1 parent e289647 commit 84ff923
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion v8go.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1301,11 +1301,15 @@ RtnStrings ObjectGetPropertyNames(ValuePtr ptr) {
}

uint32_t length = names->Length();
const char** strings = new const char*[length];
const char** strings = (const char**)malloc(length * sizeof(const char*));

for (uint32_t i = 0; i < length; i++) {
Local<Value> name_from_array;
if (!names->Get(local_ctx, i).ToLocal(&name_from_array)) {
for (i = i - 1; i > 0; i--) {
free(&strings[i]);
}
free(strings);
rtn.error = ExceptionError(try_catch, iso, local_ctx);
return rtn;
}
Expand Down

0 comments on commit 84ff923

Please sign in to comment.