<?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>11917</bug_id>
          
          <creation_ts>2006-12-21 10:27:32 -0800</creation_ts>
          <short_desc>setlocale() can return null</short_desc>
          <delta_ts>2007-01-07 21:33:31 -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>JavaScriptCore</component>
          <version>420+</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Carson">dacarson</reporter>
          <assigned_to name="David Carson">dacarson</assigned_to>
          <cc>darin</cc>
    
    <cc>ddkilzer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>40763</commentid>
    <comment_count>0</comment_count>
    <who name="David Carson">dacarson</who>
    <bug_when>2006-12-21 10:27:32 -0800</bug_when>
    <thetext>According to the spec, 
http://www.opengroup.org/onlinepubs/007908799/xsh/setlocale.html
setlocale() can return null, and it does in some environments. We should check full null when it is being used in date_object.cpp</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40732</commentid>
    <comment_count>1</comment_count>
      <attachid>11956</attachid>
    <who name="David Carson">dacarson</who>
    <bug_when>2006-12-21 14:26:18 -0800</bug_when>
    <thetext>Created attachment 11956
patch to CString

Took the approach that CString should support holding null char pointers.
Had no luck with 24fun JSBench giving consistant results with no changes, so the performance impact of this change I am not sure of.
Would love feedback from a non-mac port as setlocale() is only used in non-darwin builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40273</commentid>
    <comment_count>2</comment_count>
      <attachid>11956</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-12-22 17:48:36 -0800</bug_when>
    <thetext>Comment on attachment 11956
patch to CString

+    length = data = c;

We don&apos;t normally do multiple assignments on a line like this, and I think it&apos;s a little strange to set length to a null pointer to zero it. Instead it should be &quot;length = 0; data = 0;&quot; on two separate lines.

Otherwise, looks great. r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40274</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-12-22 17:49:48 -0800</bug_when>
    <thetext>I&apos;m a little concerned about under what circumstances setlocale() would be returning NULL. As far as I know, it only does that when it fails to change the locale, so I think there&apos;d need to be handling for that case other than just leaving the locale as-is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36413</commentid>
    <comment_count>4</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-07 21:08:30 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; I&apos;m a little concerned about under what circumstances setlocale() would be
&gt; returning NULL. As far as I know, it only does that when it fails to change the
&gt; locale, so I think there&apos;d need to be handling for that case other than just
&gt; leaving the locale as-is.

Here&apos;s a Linux man page for setlocale():  http://man.cx/setlocale(3C)

According to this man page, calling setlocale() with a NULL locale (second argument) does not change the locale, but simply returns the current one.  Since the oldlocale variable in DateProtoFunc::callAsFunction() in JavaScriptCore/kjs/date_object.cpp is never used again, I&apos;m not sure that code actually does anything.

Doing more research, this code originates from r6 (yes, revision 6) when source from kde-2.2 was imported into the then-CVS repository.  The original call to setlocale that actually changed the locale and the code that changed the locale back has long since been removed.  (See &quot;svn ann -r1023 JavaScriptCore/kjs/date_object.cpp&quot; for enlightenment.)

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36414</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-07 21:10:05 -0800</bug_when>
    <thetext>Better link:  http://man.cx/setlocale%283C%29

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36417</commentid>
    <comment_count>6</comment_count>
      <attachid>12292</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-07 21:14:12 -0800</bug_when>
    <thetext>Created attachment 12292
Patch v2

Remove dead code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36418</commentid>
    <comment_count>7</comment_count>
      <attachid>11956</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-07 21:14:50 -0800</bug_when>
    <thetext>Comment on attachment 11956
patch to CString

Clearing darin&apos;s r+ flag.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36366</commentid>
    <comment_count>8</comment_count>
      <attachid>12292</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2007-01-07 21:21:52 -0800</bug_when>
    <thetext>Comment on attachment 12292
Patch v2

r=me; clearly the best short term solution to this problem

On the other hand, the code probably meant to set the locale to &quot;&quot; or &quot;C&quot; or &quot;POSIX&quot; -- maybe some day we&apos;ll find ourselves adding code to do that. We&apos;ll need to test date-related tests on platforms other than Mac OS X with the current locale set to exotic ones to find out if that is needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36370</commentid>
    <comment_count>9</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-01-07 21:33:31 -0800</bug_when>
    <thetext>Committed revision 18658.

</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>11956</attachid>
            <date>2006-12-21 14:26:18 -0800</date>
            <delta_ts>2007-01-07 21:14:50 -0800</delta_ts>
            <desc>patch to CString</desc>
            <filename>setlocale.txt</filename>
            <type>text/plain</type>
            <size>1643</size>
            <attacher name="David Carson">dacarson</attacher>
            
              <data encoding="base64">SW5kZXg6IEphdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBKYXZhU2NyaXB0
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDE4Mzc3KQorKysgSmF2YVNjcmlwdENvcmUvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTYgQEAKKzIwMDYtMTItMjEgIGRhY2Fyc29u
ICBkYWNhcnNvbkBnbWFpbC5jb20KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMh
KS4KKworCUZpeCBmb3I6IGh0dHA6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTEx
OTE3CisgICAgICAgIENoYW5nZSBDU3RyaW5nIHRvIHN1cHBvcnQgTlVMTCBwb2ludGVycy4gVGhp
cyBpcyB0aGUgY2FzZQorICAgICAgICB3aGVuIHNldGxvY2FsZSgpIGlzIGNhbGxlZCBpbiBkYXRl
X29iamVjdC5jcHAsIHNldGxvY2FsZSgpCisgICAgICAgIGNhbiByZXR1cm4gTlVMTCwgaXQncyBy
ZXR1cm4gdmFsdWUgaXMgc3RvcmVkIGluIENTdHJpbmcuCisKKyAgICAgICAgKiBranMvdXN0cmlu
Zy5jcHA6CisgICAgICAgIChLSlM6OkNTdHJpbmc6OkNTdHJpbmcpOgorICAgICAgICAoS0pTOjpD
U3RyaW5nOjpvcGVyYXRvcj0pOgorCiAyMDA2LTEyLTIwICBBbmRlcnMgQ2FybHNzb24gIDxhY2Fy
bHNzb25AYXBwbGUuY29tPgogCiAgICAgICAgICoga2pzL3N0cmluZ19vYmplY3QuY3BwOgpJbmRl
eDogSmF2YVNjcmlwdENvcmUva2pzL3VzdHJpbmcuY3BwCj09PT09PT09PT09PT09PT09PT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gZGF0YSA9IGM7CiAKICAgcmV0dXJuICp0aGlzOwogfQo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>12292</attachid>
            <date>2007-01-07 21:14:12 -0800</date>
            <delta_ts>2007-01-07 21:21:52 -0800</delta_ts>
            <desc>Patch v2</desc>
            <filename>bug-11917-v2.diff</filename>
            <type>text/plain</type>
            <size>1225</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">SW5kZXg6IEphdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBKYXZhU2NyaXB0
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDE4NjU1KQorKysgSmF2YVNjcmlwdENvcmUvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMTMgQEAKKzIwMDctMDEtMDcgIERhdmlkIEtp
bHplciAgPGRka2lsemVyQHdlYmtpdC5vcmc+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZ
IChPT1BTISkuCisKKyAgICAgICAgLSBmaXggaHR0cDovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1
Zy5jZ2k/aWQ9MTE5MTcKKyAgICAgICAgICBzZXRsb2NhbGUoKSBjYW4gcmV0dXJuIG51bGwKKwor
ICAgICAgICAqIGtqcy9kYXRlX29iamVjdC5jcHA6CisgICAgICAgIChLSlM6OkRhdGVQcm90b0Z1
bmM6OmNhbGxBc0Z1bmN0aW9uKTogUmVtb3ZlZCBkZWFkIGNvZGUuCisKIDIwMDctMDEtMDQgIERh
dmlkIEtpbHplciAgPGRka2lsemVyQHdlYmtpdC5vcmc+CiAKICAgICAgICAgUmV2aWV3ZWQgYnkg
S2V2aW4gTWNDdWxsb3VnaC4KSW5kZXg6IEphdmFTY3JpcHRDb3JlL2tqcy9kYXRlX29iamVjdC5j
cHAKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PQotLS0gSmF2YVNjcmlwdENvcmUva2pzL2RhdGVfb2JqZWN0LmNwcAkocmV2
aXNpb24gMTg2NTUpCisrKyBKYXZhU2NyaXB0Q29yZS9ranMvZGF0ZV9vYmplY3QuY3BwCSh3b3Jr
aW5nIGNvcHkpCkBAIC00NTEsMTIgKzQ1MSw2IEBAIEpTVmFsdWUgKkRhdGVQcm90b0Z1bmM6OmNh
bGxBc0Z1bmN0aW9uKEUKIAogICBKU1ZhbHVlICpyZXN1bHQgPSAwOwogICBVU3RyaW5nIHM7Ci0j
aWYgIVBMQVRGT1JNKERBUldJTikKLSAgQ1N0cmluZyBvbGRsb2NhbGUgPSBzZXRsb2NhbGUoTENf
VElNRSwgMCk7Ci0gIGlmICghb2xkbG9jYWxlLnNpemUoKSkKLSAgICBvbGRsb2NhbGUgPSBzZXRs
b2NhbGUoTENfQUxMLCAwKTsKLSAgLy8gRklYTUU6IFdoZXJlJ3MgdGhlIGNvZGUgdG8gc2V0IHRo
ZSBsb2NhbGUgYmFjayB0byBvbGRsb2NhbGU/Ci0jZW5kaWYKICAgSlNWYWx1ZSAqdiA9IHRoaXNE
YXRlT2JqLT5pbnRlcm5hbFZhbHVlKCk7CiAgIGRvdWJsZSBtaWxsaSA9IHYtPnRvTnVtYmVyKGV4
ZWMpOwogICBpZiAoaXNOYU4obWlsbGkpKSB7Cg==
</data>
<flag name="review"
          id="4584"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>