Skip to content

Commit

Permalink
fix: TypeEncoding might be initialized with random data (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
edusperoni authored and NathanWalker committed Mar 7, 2022
1 parent 2ad6ced commit 02d681e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NativeScript/runtime/ClassBuilder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@
std::string methodNameStr = tns::ToString(isolate, methodName);
SEL selector = sel_registerName(methodNameStr.c_str());

TypeEncoding* typeEncoding = reinterpret_cast<TypeEncoding*>(malloc((argsCount + 1) * sizeof(TypeEncoding)));
TypeEncoding* typeEncoding = reinterpret_cast<TypeEncoding*>(calloc((argsCount + 1), sizeof(TypeEncoding)));
typeEncoding->type = returnType;

if (!paramsVal.IsEmpty() && paramsVal->IsArray()) {
Expand Down
2 changes: 1 addition & 1 deletion NativeScript/runtime/InteropTypes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
}

const TypeEncoding* Interop::CreateEncoding(BinaryTypeEncodingType type) {
TypeEncoding* typeEncoding = reinterpret_cast<TypeEncoding*>(malloc(sizeof(TypeEncoding)));
TypeEncoding* typeEncoding = reinterpret_cast<TypeEncoding*>(calloc(1, sizeof(TypeEncoding)));
typeEncoding->type = type;

return typeEncoding;
Expand Down

0 comments on commit 02d681e

Please sign in to comment.