Fix compilation trace memory management problem

This fixes issue with compilation trace buffer getting released upon return from VM code to Dart code, before it gets change to save to a file in natives.dart saveCompilationTrace().
This commit is contained in:
Stanislav Baranov
2018-07-26 16:08:12 -07:00
committed by GitHub
parent e690f59b65
commit caf14ff364

View File

@@ -214,12 +214,23 @@ void SaveCompilationTrace(Dart_NativeArguments args) {
return;
}
result = Dart_NewExternalTypedData(Dart_TypedData_kUint8, buffer, length);
result = Dart_NewTypedData(Dart_TypedData_kUint8, length);
if (Dart_IsError(result)) {
Dart_SetReturnValue(args, result);
return;
}
Dart_TypedData_Type type;
void* data = nullptr;
intptr_t size = 0;
Dart_Handle status = Dart_TypedDataAcquireData(result, &type, &data, &size);
if (Dart_IsError(status)) {
Dart_SetReturnValue(args, status);
return;
}
memcpy(data, buffer, length);
Dart_TypedDataReleaseData(result);
Dart_SetReturnValue(args, result);
}