Skip to content

Commit

Permalink
safety fix in case code incorrectly tries to use the reuslt of forwar…
Browse files Browse the repository at this point in the history
…ding a method to the undo manager.
  • Loading branch information
rfm committed Oct 29, 2024
1 parent 4f0a8d6 commit 156be3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
2024-10-29 Richard Frith-Macdonald <[email protected]>

* Source/NSUndoManager.m: set zero/nil return value when forwarding
invocation ... in case calling code tries to use the result.

2024-10-28 Hugo Melder <[email protected]>

* Source/NSString.m:
-commonPrefixWithString:options: returns nil when string supplied as
first argument is nil. On macOS, the empty string is returned instead.
Expand Down
7 changes: 7 additions & 0 deletions Source/NSUndoManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ - (void) endUndoGrouping
*/
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
NSUInteger size = [[anInvocation methodSignature] methodReturnLength];
unsigned char v[size];

memset(v, '\0', size);

if (_disableCount == 0)
{
if (_nextTarget == nil)
Expand Down Expand Up @@ -466,6 +471,8 @@ - (void) forwardInvocation: (NSInvocation*)anInvocation
_runLoopGroupingPending = YES;
}
}

[anInvocation setReturnValue: (void*)v];
}

/**
Expand Down

0 comments on commit 156be3a

Please sign in to comment.