Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / external / pdfium / ubsan.patch
blobf1d3552b20d25ec04215b20d4bd1a524802d69ab
1 --- core/fxcrt/string_data_template.cpp
2 +++ core/fxcrt/string_data_template.cpp
3 @@ -73,7 +73,7 @@
4 size_t nLen) {
5 DCHECK_GE(nLen, 0);
6 DCHECK_LE(nLen, m_nAllocLength);
7 - memcpy(m_String, pStr, nLen * sizeof(CharType));
8 + if (nLen != 0) memcpy(m_String, pStr, nLen * sizeof(CharType));
9 m_String[nLen] = 0;
12 @@ -82,7 +82,8 @@ void StringDataTemplate<CharType>::CopyContentsAt(size_t offset,
13 DCHECK_GE(offset, 0);
14 DCHECK_GE(nLen, 0);
15 DCHECK_LE(offset + nLen, m_nAllocLength);
16 - memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
17 + if (nLen != 0)
18 + memcpy(m_String + offset, pStr, nLen * sizeof(CharType));
19 m_String[offset + nLen] = 0;
22 --- core/fxge/cfx_glyphcache.cpp
23 +++ core/fxge/cfx_glyphcache.cpp
24 @@ -183,7 +183,8 @@ std::unique_ptr<CFX_GlyphBitmap> CFX_GlyphCache::RenderGlyph(
27 } else {
28 - memset(pDestBuf, 0, dest_pitch * bmheight);
29 + if (dest_pitch != 0 && bmheight != 0)
30 + memset(pDestBuf, 0, dest_pitch * bmheight);
31 int rowbytes = std::min(abs(src_pitch), dest_pitch);
32 for (int row = 0; row < bmheight; row++)
33 memcpy(pDestBuf + row * dest_pitch, pSrcBuf + row * src_pitch, rowbytes);