Skip to content

Commit

Permalink
[release/6.0.3xx] [runtime] Fix 'skip_nested_brace' to not read past …
Browse files Browse the repository at this point in the history
…the string. Fixes #15253. (#15462)

Fix 'skip_nested_brace' to not double skip characters.

Also add a test.

Fixes #15253.


Backport of #15257

Co-authored-by: Rolf Bjarne Kvinge <[email protected]>
  • Loading branch information
1 parent 67ea402 commit 5889016
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
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 @@ -74,6 +74,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 @@ -5423,7 +5453,6 @@ public static unsafe void Invoke (IntPtr block, nint value)
}
}
#endif // !__WATCHOS__ && !__TVOS__

}

#if !__WATCHOS__
Expand Down

5 comments on commit 5889016

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📋 [CI Build] API Diff 📋

API Current PR diff

✅ API Diff (from PR only) (no change)

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

API diff

✅ API Diff from stable

View API diff
View dotnet API diff
View dotnet legacy API diff
View dotnet iOS-MacCatalayst API diff

Generator diff

Generator Diff (no change)

Pipeline on Agent XAMMINI-056.Monterey
Hash: 5889016a5b340588eb5befd93bcb51d71fe53130

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-050.Monterey
Hash: 5889016a5b340588eb5befd93bcb51d71fe53130

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 5889016a5b340588eb5befd93bcb51d71fe53130

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • monotouch-test

Pipeline on Agent
Hash: 5889016a5b340588eb5befd93bcb51d71fe53130

@vs-mobiletools-engineering-service2
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ [CI Build] Tests passed on VSTS: simulator tests iOS. ✅

Tests passed on VSTS: simulator tests iOS.

🎉 All 234 tests passed 🎉

Pipeline on Agent XAMBOT-1030.Monterey'
[release/6.0.3xx] [runtime] Fix 'skip_nested_brace' to not read past the string. Fixes #15253. (#15462)

Please sign in to comment.