Ignore:
Timestamp:
Jul 3, 2010, 5:11:41 PM (15 years ago)
Author:
[email protected]
Message:

Patch for https://bugs.webkit.org/show_bug.cgi?id=41553
Make StringExtras.h versions of snprintf and vsnprintf match the unix versions.

Reviewed by Darin Adler.

  • MSVC does not ensure the buffers are null terminated as the unix versions do.
  • runtime/JSGlobalObjectFunctions.cpp: Cleanup includes.
  • runtime/UString.cpp: Clean up includes.

(JSC::UString::from): Don't pass sizeof(buf) - 1, that is wrong.

  • wtf/StringExtras.h:

(snprintf): Ensure null termination of buffer.
(vsnprintf): Ditto.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.cpp

    r62414 r62457  
    3333#include <limits.h>
    3434#include <limits>
    35 #include <math.h>
    3635#include <stdio.h>
    3736#include <stdlib.h>
    38 #include <string.h>
    3937#include <wtf/ASCIICType.h>
    4038#include <wtf/Assertions.h>
     
    4341#include <wtf/Vector.h>
    4442#include <wtf/unicode/UTF8.h>
    45 #include <wtf/StringExtras.h>
    4643
    4744#if HAVE(STRINGS_H)
     
    127124        char minBuf[1 + sizeof(i) * 3];
    128125#if OS(WINDOWS)
    129         snprintf(minBuf, sizeof(minBuf) - 1, "%I64d", std::numeric_limits<long long>::min());
     126        snprintf(minBuf, sizeof(minBuf), "%I64d", std::numeric_limits<long long>::min());
    130127#else
    131         snprintf(minBuf, sizeof(minBuf) - 1, "%lld", std::numeric_limits<long long>::min());
     128        snprintf(minBuf, sizeof(minBuf), "%lld", std::numeric_limits<long long>::min());
    132129#endif
    133130        return UString(minBuf);
Note: See TracChangeset for help on using the changeset viewer.