Skip to content

Commit 3edffbf

Browse files
committed
Merge branch 'release/0.3.17'
2 parents 33c1a25 + d5eb8c8 commit 3edffbf

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

dart_native/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.17
2+
3+
* [Fix] Type encoding issue on iOS.
4+
15
## 0.3.16
26

37
* [Fix] JNI environment issue on Android.

dart_native/ios/Classes/DNBlockWrapper.m

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ - (instancetype)initWithTypeString:(char *)typeString
145145
- (void)dealloc {
146146
ffi_closure_free(_closure);
147147
free(_descriptor);
148+
for (int i = 0; i < _numberOfArguments; i++) {
149+
free((void *)_typeEncodings[i]);
150+
}
148151
free(_typeEncodings);
149152
NotifyDeallocToDart(_sequence);
150153
}
@@ -275,7 +278,17 @@ - (NSString *)_parseTypeNames:(NSString *)typeNames
275278
}
276279
}
277280

278-
*(self.typeEncodings + i) = encode.UTF8String;
281+
const char *encodeSource = encode.UTF8String;
282+
size_t typeLength = strlen(encodeSource) + 1;
283+
size_t size = sizeof(char) * typeLength;
284+
char *typePtr = (char *)malloc(size);
285+
if (typePtr == NULL) {
286+
DN_ERROR(DNCreateTypeEncodingError, @"malloc for type encoding fail: %s", encodeSource);
287+
return nil;
288+
}
289+
strlcpy(typePtr, encode.UTF8String, typeLength);
290+
self.typeEncodings[i] = typePtr;
291+
279292
int length = DNTypeLengthWithTypeName(typeStr);
280293

281294
if (i == 0) {
-456 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.

dart_native/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dart_native
22
description: Write native code using Dart. This package liberates you from native code and low performance channel.
3-
version: 0.3.16
3+
version: 0.3.17
44
homepage: https://github.com/dart-native/dart_native
55

66
environment:

0 commit comments

Comments
 (0)