Index: include/core/SkTemplates.h |
diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h |
index 3571af6706a7b13b7e07de2489fd999ebd1c4c91..6ab44394d898c58cab23f270ae3edf4a0ee64905 100644 |
--- a/include/core/SkTemplates.h |
+++ b/include/core/SkTemplates.h |
@@ -10,6 +10,7 @@ |
#ifndef SkTemplates_DEFINED |
#define SkTemplates_DEFINED |
+#include "SkMath.h" |
#include "SkTypes.h" |
#include <limits.h> |
#include <new> |
@@ -292,7 +293,12 @@ public: |
} |
if (count > N) { |
- fArray = (T*) sk_malloc_throw(count * sizeof(T)); |
+ const uint64_t size64 = sk_64_mul(count, sizeof(T)); |
+ const size_t size = static_cast<size_t>(size64); |
+ if (size != size64) { |
+ sk_out_of_memory(); |
+ } |
+ fArray = (T*) sk_malloc_throw(size); |
} else if (count > 0) { |
fArray = (T*) fStorage; |
} else { |