Skip to content

Commit

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

Fix 'skip_nested_brace' to not double skip characters.

Also add a test.

Fixes #15253.
  • Loading branch information
rolfbjarne authored Jun 14, 2022
1 parent 28d286f commit 8adbefd
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 @@ -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

4 comments on commit 8adbefd

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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: 8adbefdac8813bbcbb05e35611ba15491f903744 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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) passed 💻

All tests on macOS M1 - Mac Big Sur (11.5) passed.

Pipeline on Agent
Hash: 8adbefdac8813bbcbb05e35611ba15491f903744 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

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-062.Monterey
Hash: 8adbefdac8813bbcbb05e35611ba15491f903744 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ [CI Build] Tests failed on VSTS: simulator tests iOS ❌

Tests failed on VSTS: simulator tests iOS.

Test results

8 tests failed, 226 tests passed.

Failed tests

  • [NUnit] Mono SystemXmlTests/watchOS 32-bits - simulator/Debug: Crashed
  • [NUnit] Mono SystemWebServicesTests/watchOS 32-bits - simulator/Debug: Crashed
  • [xUnit] Mono MicrosoftCSharpXunit/watchOS 32-bits - simulator/Debug: Crashed
  • mscorlib Part 3/watchOS 32-bits - simulator/Debug: Crashed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 12.4) [dotnet]: Failed
  • introspection/iOS Unified 64-bits - simulator/Debug (iOS 12.4): Failed
  • introspection/tvOS - simulator/Debug (tvOS 12.4) [dotnet]: Failed
  • introspection/tvOS - simulator/Debug (tvOS 12.4): Failed

Pipeline on Agent XAMBOT-1033.Monterey'
[runtime] Fix 'skip_nested_brace' to not read past the string. Fixes #15253. (#15257)

Please sign in to comment.