Changeset 72114 in webkit for trunk/JavaScriptCore/wtf/text/WTFString.cpp
- Timestamp:
- Nov 16, 2010, 10:04:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/WTFString.cpp
r69414 r72114 1 1 /* 2 2 * (C) 1999 Lars Knoll ([email protected]) 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. 5 5 * … … 23 23 #include "WTFString.h" 24 24 25 #include <limits>26 25 #include <stdarg.h> 27 26 #include <wtf/ASCIICType.h> … … 33 32 #include <wtf/unicode/Unicode.h> 34 33 34 using namespace std; 35 35 36 namespace WTF { 36 37 … … 53 54 len++; 54 55 55 if (len > std::numeric_limits<unsigned>::max())56 if (len > numeric_limits<unsigned>::max()) 56 57 CRASH(); 57 58 … … 83 84 if (m_impl) { 84 85 UChar* data; 85 RefPtr<StringImpl> newImpl = 86 StringImpl::createUninitialized(m_impl->length() + str.length(), data); 86 if (str.length() > numeric_limits<unsigned>::max() - m_impl->length()) 87 CRASH(); 88 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + str.length(), data); 87 89 memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar)); 88 90 memcpy(data + m_impl->length(), str.characters(), str.length() * sizeof(UChar)); … … 101 103 if (m_impl) { 102 104 UChar* data; 103 RefPtr<StringImpl> newImpl = 104 StringImpl::createUninitialized(m_impl->length() + 1, data); 105 if (m_impl->length() >= numeric_limits<unsigned>::max()) 106 CRASH(); 107 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + 1, data); 105 108 memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar)); 106 109 data[m_impl->length()] = c; … … 118 121 if (m_impl) { 119 122 UChar* data; 120 RefPtr<StringImpl> newImpl = 121 StringImpl::createUninitialized(m_impl->length() + 1, data); 123 if (m_impl->length() >= numeric_limits<unsigned>::max()) 124 CRASH(); 125 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + 1, data); 122 126 memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar)); 123 127 data[m_impl->length()] = c; … … 179 183 ASSERT(charactersToAppend); 180 184 UChar* data; 181 if (lengthToAppend > std::numeric_limits<unsigned>::max() - length())185 if (lengthToAppend > numeric_limits<unsigned>::max() - length()) 182 186 CRASH(); 183 RefPtr<StringImpl> newImpl = 184 StringImpl::createUninitialized(length() + lengthToAppend, data); 187 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() + lengthToAppend, data); 185 188 memcpy(data, characters(), length() * sizeof(UChar)); 186 189 memcpy(data + length(), charactersToAppend, lengthToAppend * sizeof(UChar)); … … 202 205 ASSERT(charactersToInsert); 203 206 UChar* data; 204 if (lengthToInsert > std::numeric_limits<unsigned>::max() - length())207 if (lengthToInsert > numeric_limits<unsigned>::max() - length()) 205 208 CRASH(); 206 RefPtr<StringImpl> newImpl = 207 StringImpl::createUninitialized(length() + lengthToInsert, data); 209 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() + lengthToInsert, data); 208 210 memcpy(data, characters(), position * sizeof(UChar)); 209 211 memcpy(data + position, charactersToInsert, lengthToInsert * sizeof(UChar)); … … 238 240 lengthToRemove = length() - position; 239 241 UChar* data; 240 RefPtr<StringImpl> newImpl = 241 StringImpl::createUninitialized(length() - lengthToRemove, data); 242 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data); 242 243 memcpy(data, characters(), position * sizeof(UChar)); 243 244 memcpy(data + position, characters() + position + lengthToRemove, … … 726 727 String String::fromUTF8(const char* stringStart, size_t length) 727 728 { 728 if (length > std::numeric_limits<unsigned>::max())729 if (length > numeric_limits<unsigned>::max()) 729 730 CRASH(); 730 731 … … 788 789 static inline IntegralType toIntegralType(const UChar* data, size_t length, bool* ok, int base) 789 790 { 790 static const IntegralType integralMax = std::numeric_limits<IntegralType>::max();791 static const bool isSigned = std::numeric_limits<IntegralType>::is_signed;791 static const IntegralType integralMax = numeric_limits<IntegralType>::max(); 792 static const bool isSigned = numeric_limits<IntegralType>::is_signed; 792 793 const IntegralType maxMultiplier = integralMax / base; 793 794
Note:
See TracChangeset
for help on using the changeset viewer.