Closed Bug 1698704 Opened 4 years ago Closed 4 years ago

Objective C exceptions in nsMacSharingService::GetSharingProviders: NSInvalidArgumentException: *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]

Categories

(Core :: Widget: Cocoa, defect, P1)

All
macOS
defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: mstange, Assigned: mstange)

Details

(Whiteboard: [mac:stability] )

Attachments

(1 file)

This exception was found in the following crash reports:
https://crash-stats.mozilla.org/report/index/5d7dd5db-0f20-4246-b8a1-831c10210311
https://crash-stats.mozilla.org/report/index/1c57bb22-73b3-4376-99d2-6c9b70210313

It seems that nsMacSharingService::GetSharingProviders sometimes gets called with invalid URL strings. Then +[NSURL URLWithString:] returns nil, and then creating an NSArray for the nil URL fails, because NSArrays cannot contain nil elements.

This achieves the same as the previous code, but without an Objective C exception.
Before this patch, we could have called [NSArray arrayWithObject:nil], which would
have thrown an exception, which we would then have caught and turned into NS_ERROR_FAILURE.

Pushed by mstange@themasta.com: https://hg.mozilla.org/integration/autoland/rev/2f40d9c4e5f5 Return early if the created NSURL is nil. r=mac-reviewers,bradwerth
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: