mtklein 2015-12-09 10:02:14 -08:00 committed by Commit bot
parent f9e658b1d6
commit 02046c50b2
2 changed files with 6 additions and 2 deletions

View File

@ -100,7 +100,10 @@ SK_API extern void* sk_calloc_throw(size_t size);
// bzero is safer than memset, but we can't rely on it, so... sk_bzero()
static inline void sk_bzero(void* buffer, size_t size) {
memset(buffer, 0, size);
// Please c.f. sk_careful_memcpy. It's undefined behavior to call memset(null, 0, 0).
if (size) {
memset(buffer, 0, size);
}
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -693,7 +693,8 @@ private:
// Store 'saveLayer ops from enclosing picture' + drawPict op + 'ops from sub-picture'
dst.fKeySize = fSaveLayerOpStack.count() + src.fKeySize + 1;
dst.fKey = new int[dst.fKeySize];
memcpy(dst.fKey, fSaveLayerOpStack.begin(), fSaveLayerOpStack.count() * sizeof(int));
sk_careful_memcpy(dst.fKey, fSaveLayerOpStack.begin(),
fSaveLayerOpStack.count() * sizeof(int));
dst.fKey[fSaveLayerOpStack.count()] = fFillBounds.currentOp();
memcpy(&dst.fKey[fSaveLayerOpStack.count()+1], src.fKey, src.fKeySize * sizeof(int));
}