Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2356)

Unified Diff: core/src/fxcrt/fx_basic_bstring.cpp

Issue 1125493002: Merge to XFA: CFX_ByteString/WideString header changes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_bstring.cpp
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 2c8f7a766bfa873cb452b10ac1d620e1689b3e15..9cf084c2fbc77fc980a2a0ec45f5bde3385d7eee 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <stddef.h> // For offsetof().
+
#include "../../include/fxcrt/fx_basic.h"
#include "../../../third_party/base/numerics/safe_math.h"
@@ -53,7 +55,9 @@ static CFX_StringData* FX_AllocString(int nLen)
return NULL;
}
- int overhead = sizeof(long) * 3 + 1; // 3 longs in header plus 1 for NUL.
+ // Fixed portion of header plus a NUL char not included in m_nAllocLength.
+ // sizeof(FX_CHAR) is always 1, used for consistency with CFX_Widestring.
+ int overhead = offsetof(CFX_StringData, m_String) + sizeof(FX_CHAR);
pdfium::base::CheckedNumeric<int> nSize = nLen;
nSize += overhead;
« no previous file with comments | « core/include/fxcrt/fx_string.h ('k') | core/src/fxcrt/fx_basic_wstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698