blob: 51fc8aa0a31559bac9277363a68ba7b16cf401ab [file] [log] [blame] [edit]
diff --git a/Source/WTF/wtf/HashTable.h b/Source/WTF/wtf/HashTable.h
index 022e281cc93a..e6a950fd4009 100644
--- a/Source/WTF/wtf/HashTable.h
+++ b/Source/WTF/wtf/HashTable.h
@@ -845,7 +845,7 @@ namespace WTF {
// This initializes the bucket without copying the empty value.
// That makes it possible to use this with types that don't support copying.
// The memset to 0 looks like a slow operation but is optimized by the compilers.
- memset(&bucket, 0, sizeof(bucket));
+ memset(static_cast<void*>(&bucket), 0, sizeof(bucket));
}
};
diff --git a/Source/WTF/wtf/Vector.h b/Source/WTF/wtf/Vector.h
index cfcb6bbac5ab..80ee20b368fa 100644
--- a/Source/WTF/wtf/Vector.h
+++ b/Source/WTF/wtf/Vector.h
@@ -96,7 +96,7 @@ struct VectorInitializer<true, true, T>
{
static void initializeIfNonPOD(T* begin, T* end)
{
- memset(begin, 0, reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin));
+ memset(static_cast<void*>(begin), 0, reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin));
}
static void initialize(T* begin, T* end)
@@ -141,11 +141,11 @@ struct VectorMover<true, T>
{
static void move(const T* src, const T* srcEnd, T* dst)
{
- memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memcpy(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
static void moveOverlapping(const T* src, const T* srcEnd, T* dst)
{
- memmove(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memmove(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
};
@@ -171,7 +171,7 @@ struct VectorCopier<true, T>
{
static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
{
- memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
+ memcpy(static_cast<void*>(dst), static_cast<void*>(const_cast<T*>(src)), reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
}
template<typename U>
static void uninitializedCopy(const T* src, const T* srcEnd, U* dst)
diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp
index 3998f313e0f6..31b8a2b78c32 100644
--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ b/Source/WebCore/accessibility/AXObjectCache.cpp
@@ -1710,7 +1710,9 @@ CharacterOffset AXObjectCache::startOrEndCharacterOffsetForRange(RefPtr<Range> r
void AXObjectCache::startOrEndTextMarkerDataForRange(TextMarkerData& textMarkerData, RefPtr<Range> range, bool isStart)
{
- memset(&textMarkerData, 0, sizeof(TextMarkerData));
+ // This memory must be zero'd so instances of TextMarkerData can be tested for byte-equivalence.
+ // Warning: This is risky and bad because TextMarkerData is a nontrivial type.
+ memset(static_cast<void*>(&textMarkerData), 0, sizeof(TextMarkerData));
CharacterOffset characterOffset = startOrEndCharacterOffsetForRange(range, isStart);
if (characterOffset.isNull())
@@ -1767,7 +1767,10 @@ CharacterOffset AXObjectCache::characterOffsetForNodeAndOffset(Node& node, int o
void AXObjectCache::textMarkerDataForCharacterOffset(TextMarkerData& textMarkerData, const CharacterOffset& characterOffset)
{
- memset(&textMarkerData, 0, sizeof(TextMarkerData));
+ // This memory must be zero'd so instances of TextMarkerData can be tested for byte-equivalence.
+ // Warning: This is risky and bad because TextMarkerData is a nontrivial type.
+ memset(static_cast<void*>(&textMarkerData), 0, sizeof(TextMarkerData));
+
setTextMarkerDataWithCharacterOffset(textMarkerData, characterOffset);
}
@@ -1875,7 +1875,8 @@ std::optional<TextMarkerData> AXObjectCache::textMarkerDataForVisiblePosition(co
{
// This memory must be bzero'd so instances of TextMarkerData can be tested for byte-equivalence.
// This also allows callers to check for failure by looking at textMarkerData upon return.
- memset(&textMarkerData, 0, sizeof(TextMarkerData));
+ // Warning: This is risky and bad because TextMarkerData is a nontrivial type.
+ memset(static_cast<void*>(&textMarkerData), 0, sizeof(TextMarkerData));
if (visiblePos.isNull())
return;
diff --git a/Source/WebCore/css/CSSSelectorList.cpp b/Source/WebCore/css/CSSSelectorList.cpp
index 57efa67d0b3e..4fc69838c710 100644
--- a/Source/WebCore/css/CSSSelectorList.cpp
+++ b/Source/WebCore/css/CSSSelectorList.cpp
@@ -67,7 +67,7 @@ void CSSSelectorList::adoptSelectorVector(Vector<std::unique_ptr<CSSParserSelect
{
// Move item from the parser selector vector into m_selectorArray without invoking destructor (Ugh.)
CSSSelector* currentSelector = current->releaseSelector().release();
- memcpy(&m_selectorArray[arrayIndex], currentSelector, sizeof(CSSSelector));
+ memcpy(static_cast<void*>(&m_selectorArray[arrayIndex]), static_cast<void*>(currentSelector), sizeof(CSSSelector));
// Free the underlying memory without invoking the destructor.
operator delete (currentSelector);
diff --git a/Source/WebCore/platform/Length.h b/Source/WebCore/platform/Length.h
index 64a08e8c1b4f..bf14421af35f 100644
--- a/Source/WebCore/platform/Length.h
+++ b/Source/WebCore/platform/Length.h
@@ -196,7 +196,7 @@ inline Length& Length::operator=(const Length& other)
if (isCalculated())
deref();
- memcpy(this, &other, sizeof(Length));
+ memcpy(static_cast<void*>(this), static_cast<void*>(const_cast<Length*>(&other)), sizeof(Length));
return *this;
}
@@ -208,7 +208,7 @@ inline Length& Length::operator=(Length&& other)
if (isCalculated())
deref();
- memcpy(this, &other, sizeof(Length));
+ memcpy(static_cast<void*>(this), static_cast<void*>(&other), sizeof(Length));
other.m_type = Auto;
return *this;
}
diff --git a/Source/WebCore/platform/graphics/Gradient.cpp b/Source/WebCore/platform/graphics/Gradient.cpp
index e7f8c6710153..8994c021edfb 100644
--- a/Source/WebCore/platform/graphics/Gradient.cpp
+++ b/Source/WebCore/platform/graphics/Gradient.cpp
@@ -213,7 +213,8 @@ unsigned Gradient::hash() const
COMPILE_ASSERT(!(sizeof(ColorStop) % 2), Color_stop_size_should_be_multiple_of_two);
// Ensure that any padding in the struct is zero-filled, so it will not affect the hash value.
- memset(&parameters, 0, sizeof(parameters));
+ // FIXME: This is asking for trouble, because it is a nontrivial type.
+ memset(static_cast<void*>(&parameters), 0, sizeof(parameters));
WTF::switchOn(m_data,
[&parameters] (const LinearData& data) {
diff --git a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
index d3fc934fe4be..bd9cd0009afb 100644
--- a/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
+++ b/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
@@ -48,7 +48,7 @@ FontCustomPlatformData::FontCustomPlatformData(FT_Face freeTypeFace, SharedBuffe
// this cairo_font_face_t is destroyed, it cleans up the FreeType face as well.
static cairo_user_data_key_t freeTypeFaceKey;
cairo_font_face_set_user_data(m_fontFace, &freeTypeFaceKey, freeTypeFace,
- reinterpret_cast<cairo_destroy_func_t>(FT_Done_Face));
+ reinterpret_cast<cairo_destroy_func_t>(reinterpret_cast<GCallback>(FT_Done_Face)));
}
FontCustomPlatformData::~FontCustomPlatformData()