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

Unified Diff: include/core/SkTArray.h

Issue 1510683002: Add sk_careful_memcpy to catch undefined behavior in memcpy. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: two more Created 5 years 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
Index: include/core/SkTArray.h
diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h
index 401f7084d6e548e0e7931f88031b973549ab735b..409998e1e18bef24b71eae319cb5dc997f2c8b87 100644
--- a/include/core/SkTArray.h
+++ b/include/core/SkTArray.h
@@ -23,11 +23,15 @@ inline void copy(SkTArray<T, true>* self, int dst, int src) {
}
template<typename T>
inline void copy(SkTArray<T, true>* self, const T* array) {
- memcpy(self->fMemArray, array, self->fCount * sizeof(T));
+ if (array) {
+ memcpy(self->fMemArray, array, self->fCount * sizeof(T));
+ }
}
template<typename T>
inline void copyAndDelete(SkTArray<T, true>* self, char* newMemArray) {
tomhudson 2015/12/08 16:31:40 Oddly, this doesn't delete anything?
- memcpy(newMemArray, self->fMemArray, self->fCount * sizeof(T));
+ if (self->fMemArray) {
+ memcpy(newMemArray, self->fMemArray, self->fCount * sizeof(T));
+ }
}
template<typename T>
« no previous file with comments | « gyp/yasm.gyp ('k') | include/core/SkTDArray.h » ('j') | include/core/SkTDArray.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698