Skip to content

Commit 4aa512d

Browse files
committed
[Bug 14826] com.livecode.foreign: Error for nul in ZStringNative.
Throw an error when attempting to export a string containing the nul character (U+0000) to a ZStringNative.
1 parent f3e9e3b commit 4aa512d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libscript/src/module-foreign.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ static bool __nativecstring_import(void *contents, bool release, MCValueRef& r_v
133133

134134
static bool __nativecstring_export(MCValueRef value, bool release, void *contents)
135135
{
136+
if (!MCForeignEvalStringNonNull ((MCStringRef) value))
137+
return false;
138+
136139
char *t_cstring_value;
137140
if (!MCStringConvertToCString((MCStringRef)value, t_cstring_value))
138141
return false;

tests/lcb/stdlib/foreign.lcb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ module com.livecode.foreign.tests
2020
use com.livecode.foreign
2121
use com.livecode.__INTERNAL._testlib
2222

23+
handler TestZStringNative_Null()
24+
variable t as ZStringNative
25+
put "\u{0}" into t
26+
end handler
27+
public handler TestZStringNative()
28+
-- bug 14826
29+
-- Check that strings containing embedded nuls can't be
30+
-- bridged.
31+
MCUnitTestHandlerThrows(TestZStringNative_Null, "ZStringNative (nulls")
32+
end handler
33+
2334
handler TestZStringUTF16_Null()
2435
variable t as ZStringUTF16
2536
put "\u{0}" into t

0 commit comments

Comments
 (0)