Commit 4af8e56
committed
platform_darwin: fix URLForResource filter dir extraction
GCC on 10.5 SDK emitted:
platform_darwin.m:465: warning: passing argument 2 of strlcpy
from incompatible pointer type
ROOT CAUSE: the expression [[url baseURL] fileSystemRepresentation]
had two separate problems.
1. LOGIC BUG (preexisting, silent): -[NSURL baseURL] returns the URL
that the receiver was constructed relative to. For URLs made
absolutely - which is what -[NSBundle URLForResource:withExtension:
subdirectory:] returns - baseURL is nil. Messaging
-fileSystemRepresentation on nil returns (const char *)0, and
strlcpy then reads from a NULL source pointer. This was a latent
bug that predates this audit.
2. COMPILE WARNING (the reported symptom): on the 10.5 SDK, NSURL
doesn't declare -fileSystemRepresentation (that selector was only
added to NSURL in 10.9). GCC 4.0 resolves the selector against
NSString's declaration - which returns const char * and would
match strlcpy - but warns about incompatible pointer type because
the receiver [url baseURL] is typed NSURL*, not NSString*.
FIX: replace both sites with
[[[url path] stringByDeletingLastPathComponent] UTF8String]
All three selectors are 10.0-era NSString methods, unambiguous, and
warning-clean. Also semantically correct: URLForResource:nil with
a subdirectory returns the URL of the *first matching file* in that
subdirectory; what we want is its containing directory, which is
exactly what stringByDeletingLastPathComponent gives us.
The pattern matches ui/drivers/ui_cocoa.m:193 which already does
[url.path UTF8String] for the same NSURL-to-C-string conversion.
No behavioral change on bundles that don't ship inline filter files
(the URLForResource: call returns nil and the fill_pathname_join
fallback runs as before). On bundles that do, the audio/video
filter dirs will now resolve to the correct directory instead of
dereferencing NULL.1 parent da2b16d commit 4af8e56
1 file changed
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
455 | 455 | | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
459 | 470 | | |
460 | 471 | | |
461 | 472 | | |
462 | 473 | | |
463 | 474 | | |
464 | 475 | | |
465 | | - | |
| 476 | + | |
466 | 477 | | |
467 | 478 | | |
468 | 479 | | |
| |||
0 commit comments