OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
8 #include "../../../third_party/numerics/safe_math.h" | 8 #include "../../../third_party/numerics/safe_math.h" |
9 | 9 |
10 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) | 10 static int _Buffer_itoa(char* buf, int i, FX_DWORD flags) |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 } | 1075 } |
1076 FX_DWORD CFX_ByteString::GetID(FX_STRSIZE start_pos) const | 1076 FX_DWORD CFX_ByteString::GetID(FX_STRSIZE start_pos) const |
1077 { | 1077 { |
1078 return CFX_ByteStringC(*this).GetID(start_pos); | 1078 return CFX_ByteStringC(*this).GetID(start_pos); |
1079 } | 1079 } |
1080 FX_DWORD CFX_ByteStringC::GetID(FX_STRSIZE start_pos) const | 1080 FX_DWORD CFX_ByteStringC::GetID(FX_STRSIZE start_pos) const |
1081 { | 1081 { |
1082 if (m_Length == 0) { | 1082 if (m_Length == 0) { |
1083 return 0; | 1083 return 0; |
1084 } | 1084 } |
1085 if (start_pos >= m_Length) { | 1085 if (start_pos < 0 || start_pos >= m_Length) { |
1086 return 0; | 1086 return 0; |
1087 } | 1087 } |
1088 FX_DWORD strid = 0; | 1088 FX_DWORD strid = 0; |
1089 if (start_pos + 4 > m_Length) { | 1089 if (start_pos + 4 > m_Length) { |
1090 for (FX_STRSIZE i = 0; i < m_Length - start_pos; i ++) { | 1090 for (FX_STRSIZE i = 0; i < m_Length - start_pos; i ++) { |
1091 strid = strid * 256 + m_Ptr[start_pos + i]; | 1091 strid = strid * 256 + m_Ptr[start_pos + i]; |
1092 } | 1092 } |
1093 strid = strid << ((4 - m_Length + start_pos) * 8); | 1093 strid = strid << ((4 - m_Length + start_pos) * 8); |
1094 } else { | 1094 } else { |
1095 for (int i = 0; i < 4; i ++) { | 1095 for (int i = 0; i < 4; i ++) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1); | 1169 FX_CHAR* pBuffer = (FX_CHAR*)(this + 1); |
1170 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len); | 1170 FXSYS_memcpy32(pBuffer + m_Size, str.GetPtr(), len); |
1171 m_Size += len; | 1171 m_Size += len; |
1172 } | 1172 } |
1173 void CFX_StringBufBase::Append(int i, FX_DWORD flags) | 1173 void CFX_StringBufBase::Append(int i, FX_DWORD flags) |
1174 { | 1174 { |
1175 char buf[32]; | 1175 char buf[32]; |
1176 int len = _Buffer_itoa(buf, i, flags); | 1176 int len = _Buffer_itoa(buf, i, flags); |
1177 Append(CFX_ByteStringC(buf, len)); | 1177 Append(CFX_ByteStringC(buf, len)); |
1178 } | 1178 } |
OLD | NEW |