Skip to content

Commit 31ccfc1

Browse files
Link a static call on a host interface without its missing glue (#445)
A malformed cppia file that calls a static function on a host interface no longer crashes the loader looking in script glue an interface does not have: the call fails to link like any other missing static. The fuzz input that found it is in test/fuzz/regressions/cppia. # Conflicts: # Changes.md
2 parents 919b735 + 0494706 commit 31ccfc1

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎Changes.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ libhxcpp 6.0.0 (unreleased)
99
* Fixed cpp.encoding.Utf8.encode returning a null array for the empty string, at API level 500 (libhxcpp #406)
1010
* Fixed cpp.encoding.Utf8.encode writing bytes for a code point that is no Unicode scalar value, a surrogate or one past U+10FFFF, which UTF-8 cannot hold and the UTF-16 encoder refused. Both encoders, and both getByteCount, throw for one before writing anything, at API level 500 (libhxcpp #407)
1111
* Fixed Haxe 5's Bytes.ofString keeping an array of three bytes for each unit of a string that was not all ASCII: cpp.encoding.Utf8.encode allocated for the worst case and only shortened it, so a megabyte of ASCII with one other character held 3 MB. It counts the bytes and allocates them exactly (libhxcpp #405)
12+
* Fixed a malformed cppia file that calls a static function on a host interface crashing the loader: it looked the function up in the interface's script glue, which an interface does not have. The fuzz job found it
1213
* Added timedWait to hx::thread::ConditionVariable, which Haxe 5's sys.thread.Condition.timedWait calls: with the Haxe nightly, every program that used Condition failed to compile. It returns true once a signal or broadcast came and false when the time ran out, and it waits out the wakeups MSVC's timed waits give just before the deadline with nothing signalled
1314
* Fixed an exception from blit, setSize or resize under the cppia JIT ending the process instead of reaching the script's catch, on typed arrays and on Array<Dynamic>: their native calls had no exception bridge. The script catches it, as it does interpreted and in compiled code (libhxcpp #404)
1415
* Fixed resize() and cpp.NativeArray.setSize() on an Array<Dynamic> under the cppia JIT evaluating the array expression twice, so a call in it ran twice and the array it returned the second time was the one resized. The JIT evaluates it once (libhxcpp #411)

‎src/hx/cppia/Cppia.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,9 @@ struct CallStatic : public CppiaExpr
21412141

21422142
if (!replace && type->haxeClass.mPtr)
21432143
{
2144-
ScriptNamedFunction func = type->haxeBase->findStaticFunction(field);
2144+
// A host interface has a class but no script glue, and only a
2145+
// malformed file calls a static on one
2146+
ScriptNamedFunction func = type->haxeBase ? type->haxeBase->findStaticFunction(field) : ScriptNamedFunction();
21452147
if (func.signature)
21462148
{
21472149
//CPPIALOG(" found function %s\n", func.signature );
780 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)