diff options
author | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-23 13:44:10 +0000 |
---|---|---|
committer | scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-23 13:44:10 +0000 |
commit | e9617eb352483bf152dfd3a38083ffb99c4694b9 (patch) | |
tree | 4aea8dce2333193735b0d842d3cc18bdacb26745 /src | |
parent | bfeddae9da240693441556b2f278827e213f75e8 (diff) |
In SkWriter32::writeString, initialize all memory reserved.
SkFlatData compares data which is sometimes created by writeString.
Initialize all the memory in writeString so it does not compare
uninitialized memory.
See http://code.google.com/p/skia/issues/detail?id=721&thanks=721
Review URL: https://codereview.appspot.com/6428054
git-svn-id: http://skia.googlecode.com/svn/trunk@4715 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkWriter32.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp index 2fdb13376b..23f51b93fe 100644 --- a/src/core/SkWriter32.cpp +++ b/src/core/SkWriter32.cpp @@ -280,9 +280,12 @@ void SkWriter32::writeString(const char str[], size_t len) { size_t alignedLen = SkAlign4(len + 1); char* ptr = (char*)this->reserve(alignedLen); memcpy(ptr, str, len); - ptr[len] = 0; - // we may have left 0,1,2,3 bytes uninitialized, since we reserved align4 - // number of bytes. That's ok, since the reader will know to skip those + // Add the terminating 0, and pad the rest with 0s + ptr += len; + int n = alignedLen - len; + while (--n >= 0) { + *ptr++ = 0; + } } size_t SkWriter32::WriteStringSize(const char* str, size_t len) { |