<?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>12111</bug_id>
          
          <creation_ts>2007-01-04 06:45:56 -0800</creation_ts>
          <short_desc>Uninitialized variable in -[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]</short_desc>
          <delta_ts>2008-01-01 15:37:04 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</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>
          
          <blocked>16700</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Jim Correia">jim.correia</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>opendarwin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>37158</commentid>
    <comment_count>0</comment_count>
    <who name="Jim Correia">jim.correia</who>
    <bug_when>2007-01-04 06:45:56 -0800</bug_when>
    <thetext>-[WebDefaultPolicyDelegate webView:decidePolicyForMIMEType:request:frame:decisionListener:]

has the following code in its implementation:

    if ([[request URL] isFileURL]) {
        BOOL isDirectory;
        [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&amp;isDirectory];
        
        if (isDirectory) {
            [listener ignore];


isDirectory is only filled in by the NSFileManager method in the case that the file exists. In all other cases we are using an uninitialized variable. Initializing the variable is sufficient to solve the problem.

See also rdar://problem/4908081</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37133</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-04 11:05:39 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; isDirectory is only filled in by the NSFileManager method in the case that the
&gt; file exists. In all other cases we are using an uninitialized variable.
&gt; Initializing the variable is sufficient to solve the problem.

Does the BOOL type not default to &apos;false&apos; if not explicitly set?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37116</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2007-01-04 11:56:27 -0800</bug_when>
    <thetext>Confirmed (automatic BOOL variables aren&apos;t automatically initialized).

Is this just a potential problem, or there are real life circumstances where the delegate gets called for a non-existent object?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37039</commentid>
    <comment_count>3</comment_count>
    <who name="Jim Correia">jim.correia</who>
    <bug_when>2007-01-04 14:08:50 -0800</bug_when>
    <thetext>Yes, it is a real life problem in my application. (I provided more details in radar, which I realize is only readable by Apple people.)

Essentially I&apos;m using a custom URL protocol to load web archives to avoid the problem where WebKit will load the original resource from the network or filesystem (which may no longer exist.) I&apos;m not rewriting the URLs, only providing data, so the web policy delegate will see the original file url which doesn&apos;t point to an existing path.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36950</commentid>
    <comment_count>4</comment_count>
      <attachid>12235</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-04 23:05:16 -0800</bug_when>
    <thetext>Created attachment 12235
Patch v1

The obvious fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36947</commentid>
    <comment_count>5</comment_count>
      <attachid>12235</attachid>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2007-01-04 23:11:42 -0800</bug_when>
    <thetext>Comment on attachment 12235
Patch v1

surly you mean &quot;BOOL isDirectory = NO&quot;?
otherwise r+</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36935</commentid>
    <comment_count>6</comment_count>
      <attachid>12236</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-04 23:21:50 -0800</bug_when>
    <thetext>Created attachment 12236
Patch v2 (change false to NO)

Now with correct-style points!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36927</commentid>
    <comment_count>7</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-04 23:38:48 -0800</bug_when>
    <thetext>Committed revision 18612.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65941</commentid>
    <comment_count>8</comment_count>
    <who name="Jeff Johnson">opendarwin</who>
    <bug_when>2008-01-01 14:52:40 -0800</bug_when>
    <thetext>This was not a good fix.  -[NSFileManager fileExistsAtPath:isDirectory] may or may not modify the variable isDirectory; that&apos;s a private implementation detail of NSFileManager.

What should be done is to check the return value of [[NSFileManager defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&amp;isDirectory] before using isDirectory.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65946</commentid>
    <comment_count>9</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2008-01-01 15:09:07 -0800</bug_when>
    <thetext>(In reply to comment #8)
&gt; This was not a good fix.  -[NSFileManager fileExistsAtPath:isDirectory] may or
&gt; may not modify the variable isDirectory; that&apos;s a private implementation detail
&gt; of NSFileManager.
&gt; 
&gt; What should be done is to check the return value of [[NSFileManager
&gt; defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&amp;isDirectory]
&gt; before using isDirectory.

Please open a new bug.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65952</commentid>
    <comment_count>10</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2008-01-01 15:36:37 -0800</bug_when>
    <thetext>(In reply to comment #9)
&gt; (In reply to comment #8)
&gt; &gt; This was not a good fix.  -[NSFileManager fileExistsAtPath:isDirectory] may or
&gt; &gt; may not modify the variable isDirectory; that&apos;s a private implementation detail
&gt; &gt; of NSFileManager.
&gt; &gt; 
&gt; &gt; What should be done is to check the return value of [[NSFileManager
&gt; &gt; defaultManager] fileExistsAtPath:[[request URL] path] isDirectory:&amp;isDirectory]
&gt; &gt; before using isDirectory.
&gt; 
&gt; Please open a new bug.

Bug 16700.

http://trac.webkit.org/projects/webkit/changeset/18612

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/fileExistsAtPath:isDirectory:

</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12235</attachid>
            <date>2007-01-04 23:05:16 -0800</date>
            <delta_ts>2007-01-04 23:21:50 -0800</delta_ts>
            <desc>Patch v1</desc>
            <filename>bug-12111-v1.diff</filename>
            <type>text/plain</type>
            <size>1292</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYktpdC9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gV2ViS2l0L0NoYW5nZUxvZwko
cmV2aXNpb24gMTg2MTEpCisrKyBXZWJLaXQvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0x
LDMgKzEsMTIgQEAKKzIwMDctMDEtMDUgIERhdmlkIEtpbHplciAgPGRka2lsemVyQHdlYmtpdC5v
cmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgLSBm
aXggaHR0cDovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/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dG9yeSA9
IGZhbHNlOwogICAgICAgICBbW05TRmlsZU1hbmFnZXIgZGVmYXVsdE1hbmFnZXJdIGZpbGVFeGlz
dHNBdFBhdGg6W1tyZXF1ZXN0IFVSTF0gcGF0aF0gaXNEaXJlY3Rvcnk6JmlzRGlyZWN0b3J5XTsK
ICAgICAgICAgCiAgICAgICAgIGlmIChpc0RpcmVjdG9yeSkgewo=
</data>
<flag name="review"
          id="4545"
          type_id="1"
          status="+"
          setter="beidson"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12236</attachid>
            <date>2007-01-04 23:21:50 -0800</date>
            <delta_ts>2007-01-04 23:41:30 -0800</delta_ts>
            <desc>Patch v2 (change false to NO)</desc>
            <filename>bug-12111-v2.diff</filename>
            <type>text/plain</type>
            <size>1289</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYktpdC9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gV2ViS2l0L0NoYW5nZUxvZwko
cmV2aXNpb24gMTg2MTEpCisrKyBXZWJLaXQvQ2hhbmdlTG9nCSh3b3JraW5nIGNvcHkpCkBAIC0x
LDMgKzEsMTIgQEAKKzIwMDctMDEtMDUgIERhdmlkIEtpbHplciAgPGRka2lsemVyQHdlYmtpdC5v
cmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAgICAgLSBm
aXggaHR0cDovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTIxMTEKKyAgICAgICAg
ICBVbmluaXRpYWxpemVkIHZhcmlhYmxlIGluIC1bV2ViRGVmYXVsdFBvbGljeURlbGVnYXRlIHdl
YlZpZXc6ZGVjaWRlUG9saWN5Rm9yTUlNRVR5cGU6cmVxdWVzdD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3J5XTsKICAg
ICAgICAgCiAgICAgICAgIGlmIChpc0RpcmVjdG9yeSkgewo=
</data>
<flag name="review"
          id="4546"
          type_id="1"
          status="+"
          setter="beidson"
    />
          </attachment>
      

    </bug>

</bugzilla>