<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>293591</bug_id>
          
          <creation_ts>2025-05-26 12:21:21 -0700</creation_ts>
          <short_desc>com.apple.WebKit.WebContent crash at com.apple.WebCore:  WebCore::preferredExtensionForImageType</short_desc>
          <delta_ts>2025-05-27 09:22:30 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>256867</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2119735</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2025-05-26 12:21:21 -0700</bug_when>
    <thetext>com.apple.WebKit.WebContent crash at com.apple.WebCore:  WebCore::preferredExtensionForImageType due to release assertion.

In Bug 256867, a release assert was added to verify that the value of `UTTypeCopyPreferredTagWithClass()` matched the value of `+[UTType typeWithIdentifier:]`, but in all the cases where we crash, the `UTType` method returns a valid file extension while `UTTypeCopyPreferredTagWithClass()` returned a null/empty string, so we can just switch to using the `UTType` method.

```
Thread 0 Crashed::   Dispatch queue: com.apple.main-thread
0   com.apple.JavaScriptCore      	       0x10834f77c WTFCrashWithInfoImpl(int, char const*, char const*, int, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long, unsigned long long)
1   com.apple.WebCore             	       0x119c5c818 WebCore::preferredExtensionForImageType(WTF::String const&amp;)
2   com.apple.WebCore             	       0x11ae6a0a0 WebCore::ImageDecoderCG::filenameExtension() const
3   com.apple.WebCore             	       0x11ad5ec18 WTF::String WebCore::BitmapImageDescriptor::imageMetadata&lt;WTF::String&gt;(WTF::String&amp;, WTF::String const&amp;, WebCore::BitmapImageDescriptor::CachedFlag, WTF::String (WebCore::ImageDecoder::*)() const) const
4   com.apple.WebCore             	       0x11ad5eccc WebCore::BitmapImageDescriptor::filenameExtension() const
5   com.apple.WebKit              	       0x10b311884 WebKit::WebDragClient::declareAndWriteDragImage(WTF::String const&amp;, WebCore::Element&amp;, WTF::URL const&amp;, WTF::String const&amp;, WebCore::LocalFrame*)
6   com.apple.WebCore             	       0x11ab4fc90 WebCore::DragController::startDrag(WebCore::LocalFrame&amp;, WebCore::DragState const&amp;, WTF::OptionSet&lt;WebCore::DragOperation&gt;, WebCore::PlatformMouseEvent const&amp;, WebCore::IntPoint const&amp;, WebCore::HasNonDefaultPasteboardData)
7   com.apple.WebCore             	       0x11ab60324 WebCore::EventHandler::handleDrag(WebCore::MouseEventWithHitTestResults const&amp;, WebCore::CheckDragHysteresis)
8   com.apple.WebCore             	       0x11ab5f774 WebCore::EventHandler::handleMouseDraggedEvent(WebCore::MouseEventWithHitTestResults const&amp;, WebCore::CheckDragHysteresis)
9   com.apple.WebCore             	       0x11ab66d44 WebCore::EventHandler::handleMouseMoveEvent(WebCore::PlatformMouseEvent const&amp;, WebCore::HitTestResult*, bool)
10  com.apple.WebCore             	       0x11ab6621c WebCore::EventHandler::mouseMoved(WebCore::PlatformMouseEvent const&amp;)
11  com.apple.WebKit              	       0x10b6faf84 WebKit::WebFrame::handleMouseEvent(WebKit::WebMouseEvent const&amp;)
12  com.apple.WebKit              	       0x10b70c10c WebKit::WebPage::mouseEvent(WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long long&gt;, unsigned long long&gt;&gt;, WebKit::WebMouseEvent const&amp;, std::__1::optional&lt;WTF::Vector&lt;WebKit::SandboxExtensionHandle, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;&gt;&amp;&amp;)
13  com.apple.WebKit              	       0x10af3ce50 void IPC::handleMessage&lt;Messages::WebPage::MouseEvent, IPC::Connection, WebKit::WebPage, WebKit::WebPage, void (WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long long&gt;, unsigned long long&gt;&gt;, WebKit::WebMouseEvent const&amp;, std::__1::optional&lt;WTF::Vector&lt;WebKit::SandboxExtensionHandle, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;&gt;&amp;&amp;)&gt;(IPC::Connection&amp;, IPC::Decoder&amp;, WebKit::WebPage*, void (WebKit::WebPage::*)(WebCore::ProcessQualified&lt;WTF::ObjectIdentifierGeneric&lt;WebCore::FrameIdentifierType, WTF::ObjectIdentifierMainThreadAccessTraits&lt;unsigned long long&gt;, unsigned long long&gt;&gt;, WebKit::WebMouseEvent const&amp;, std::__1::optional&lt;WTF::Vector&lt;WebKit::SandboxExtensionHandle, 0ul, WTF::CrashOnOverflow, 16ul, WTF::FastMalloc&gt;&gt;&amp;&amp;))
14  com.apple.WebKit              	       0x10af395dc WebKit::WebPage::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
15  com.apple.WebKit              	       0x10b93ce48 IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
16  com.apple.WebKit              	       0x10b258ddc WebKit::AuxiliaryProcess::dispatchMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
17  com.apple.WebKit              	       0x10ae5639c WebKit::AuxiliaryProcess::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
18  com.apple.WebKit              	       0x10b937550 IPC::Connection::dispatchMessage(WTF::UniqueRef&lt;IPC::Decoder&gt;)
19  com.apple.WebKit              	       0x10b937700 IPC::Connection::dispatchOneIncomingMessage()
20  com.apple.JavaScriptCore      	       0x1083a1c04 WTF::RunLoop::performWork()
[...]
```

&lt;rdar://132707082&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2119740</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2025-05-26 12:41:23 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/45921</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2119844</commentid>
    <comment_count>2</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-05-27 09:22:28 -0700</bug_when>
    <thetext>Committed 295449@main (3f5ad67c9783): &lt;https://commits.webkit.org/295449@main&gt;

Reviewed commits have been landed. Closing PR #45921 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>