RESOLVED FIXED 221428
WTF::dynamic_cf_cast<> should not assert in Debug builds
https://bugs.webkit.org/show_bug.cgi?id=221428
Summary WTF::dynamic_cf_cast<> should not assert in Debug builds
David Kilzer (:ddkilzer)
Reported 2021-02-04 14:01:25 PST
WTF::dynamic_cf_cast<> should not assert in Debug builds. The proper way to use dynamic_cf_cast<> is to do a nullptr check on its return results, and take action if the cast failed. One of the most common use cases is when decoding (untrusted) serialized data, and instead of crashing, we just want to fail decoding on that particular chunk serialized data. In some cases, we may way to add a nullptr check before calling it to differentiate that scenario from the wrong object type being detected. We never want to use dynamic_cf_cast<> and assume it always succeeds, though. In that case, we either want to use checked_cf_cast<> instead, or add a nullptr check to handle that scenario. <rdar://problem/73451079>
Attachments
Patch v1 (1.22 KB, patch)
2021-02-04 14:08 PST, David Kilzer (:ddkilzer)
ggaren: review+
ddkilzer: commit-queue-
Patch for landing (1.83 KB, patch)
2021-02-04 14:17 PST, David Kilzer (:ddkilzer)
ews-feeder: commit-queue-
Patch for landing v2 (1.82 KB, patch)
2021-02-04 15:17 PST, David Kilzer (:ddkilzer)
no flags
David Kilzer (:ddkilzer)
Comment 1 2021-02-04 14:08:43 PST
Created attachment 419318 [details] Patch v1
Geoffrey Garen
Comment 2 2021-02-04 14:13:14 PST
Comment on attachment 419318 [details] Patch v1 r=me
David Kilzer (:ddkilzer)
Comment 3 2021-02-04 14:17:28 PST
Created attachment 419320 [details] Patch for landing
David Kilzer (:ddkilzer)
Comment 4 2021-02-04 14:18:07 PST
Comment on attachment 419320 [details] Patch for landing Added comments about how to use each template function.
EWS
Comment 5 2021-02-04 15:00:17 PST
ChangeLog entry in Source/WTF/ChangeLog contains OOPS!.
David Kilzer (:ddkilzer)
Comment 6 2021-02-04 15:17:10 PST
Created attachment 419328 [details] Patch for landing v2
EWS
Comment 7 2021-02-04 15:52:43 PST
Committed r272392: <https://trac.webkit.org/changeset/272392> All reviewed patches have been landed. Closing bug and clearing flags on attachment 419328 [details].
Note You need to log in before you can comment on or make changes to this bug.