Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[runtime] Fix 'skip_nested_brace' to not read past the string. Fixes #15253. #15257

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion runtime/trampolines.m
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@
case '}':
return type++;
default:
type++;
break;
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/monotouch-test/ObjCRuntime/Messaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,18 @@ public struct objc_super {

[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_IntPtr_IntPtr_BlockLiteral (IntPtr receiver, IntPtr selector, IntPtr p1, IntPtr p2, ref BlockLiteral p3);

[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_NSRange_out_NSRange_ref_NSRange (IntPtr receiver, IntPtr selector, _LongNSRange p1, out _LongNSRange p2, ref _LongNSRange p3);
}

public struct _LongNSRange {
public long Location;
public long Length;
public _LongNSRange (long location, long length)
{
Location = location;
Length = length;
}
}
}
31 changes: 30 additions & 1 deletion tests/monotouch-test/ObjCRuntime/RegistrarTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,36 @@ public static Registrars CurrentRegistrar {
}
}

[Test]
public void NSRangeOutParameter ()
{
using var obj = new NSRangeOutParameterClass ();
var a = new _LongNSRange (-1, -2);
var c = new _LongNSRange (-5, -6);
Messaging.void_objc_msgSend_NSRange_out_NSRange_ref_NSRange (obj.Handle, Selector.GetHandle ("passRange:getRange:refRange:"), a, out var b, ref c);
Assert.AreEqual (a.Location, (long) (-1), "post a Location");
Assert.AreEqual (a.Length, (long) (-2), "post a Length");
Assert.AreEqual (b.Location, (long) 3, "post b Location");
Assert.AreEqual (b.Length, (long) 4, "post b Length");
Assert.AreEqual (c.Location, (long) 5, "post c Location");
Assert.AreEqual (c.Length, (long) 6, "post c Length");
}

class NSRangeOutParameterClass : NSObject {
[Export ("passRange:getRange:refRange:")]
public void DoIt (_LongNSRange a, out _LongNSRange b, ref _LongNSRange c)
{
Assert.AreEqual (a.Location, (long) (-1), "a Location");
Assert.AreEqual (a.Length, (long) (-2), "a Length");
Assert.AreEqual (c.Location, (long) (-5), "c Location");
Assert.AreEqual (c.Length, (long) (-6), "c Length");

a = new _LongNSRange (1, 2);
b = new _LongNSRange (3, 4);
c = new _LongNSRange (5, 6);
}
}

[Test]
public void RegistrarRemoval ()
{
Expand Down Expand Up @@ -5426,7 +5456,6 @@ public static unsafe void Invoke (IntPtr block, nint value)
}
}
#endif // !__WATCHOS__ && !__TVOS__

}

#if !__WATCHOS__
Expand Down