Index: src/core/SkWriter32.cpp |
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp |
index 5e89ed655b70e5d83da4df2588704689898b52e6..cb8506882780a7df172f6af71cc01ba2c0c7115a 100644 |
--- a/src/core/SkWriter32.cpp |
+++ b/src/core/SkWriter32.cpp |
@@ -44,15 +44,19 @@ void SkWriter32::writeString(const char str[], size_t len) { |
if ((long)len < 0) { |
len = strlen(str); |
} |
- this->write32(len); |
+ |
// add 1 since we also write a terminating 0 |
mtklein
2014/02/10 22:37:34
Hmm, maybe we can make this clearer? Does this wo
f(malita)
2014/02/11 03:30:56
Ah, reservePad takes care of padding, doesn't it.
|
size_t alignedLen = SkAlign4(len + 1); |
- char* ptr = (char*)this->reserve(alignedLen); |
+ // reserve an additional 4 bytes for len storage |
+ uint32_t* lenPtr = this->reserve(alignedLen + sizeof(uint32_t)); |
+ char* ptr = (char*)(lenPtr + 1); |
{ |
// Write the terminating 0 and fill in the rest with zeroes |
uint32_t* padding = (uint32_t*)(ptr + (alignedLen - 4)); |
*padding = 0; |
} |
+ |
+ *lenPtr = len; |
// Copy the string itself. |
memcpy(ptr, str, len); |
} |