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

Side by Side Diff: src/core/SkWriter32.cpp

Issue 255693003: Fixed issue found by clusterfuzz (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed nit Created 6 years, 7 months 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 unified diff | Download patch
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkReader32.h" 8 #include "SkReader32.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "SkWriter32.h" 10 #include "SkWriter32.h"
11 11
12 /* 12 /*
13 * Strings are stored as: length[4-bytes] + string_data + '\0' + pad_to_mul_4 13 * Strings are stored as: length[4-bytes] + string_data + '\0' + pad_to_mul_4
14 */ 14 */
15 15
16 const char* SkReader32::readString(size_t* outLen) { 16 const char* SkReader32::readString(size_t* outLen) {
17 size_t len = this->readInt(); 17 size_t len = this->readU32();
18 const void* ptr = this->peek(); 18 const void* ptr = this->peek();
19 19
20 // skip over the string + '\0' and then pad to a multiple of 4 20 // skip over the string + '\0' and then pad to a multiple of 4
21 size_t alignedSize = SkAlign4(len + 1); 21 size_t alignedSize = SkAlign4(len + 1);
22 this->skip(alignedSize); 22 this->skip(alignedSize);
23 23
24 if (outLen) { 24 if (outLen) {
25 *outLen = len; 25 *outLen = len;
26 } 26 }
27 return (const char*)ptr; 27 return (const char*)ptr;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // prepare us to do copy on write, by pretending the data buffer 96 // prepare us to do copy on write, by pretending the data buffer
97 // is external and size limited 97 // is external and size limited
98 mutable_this.fData = buffer; 98 mutable_this.fData = buffer;
99 mutable_this.fCapacity = fUsed; 99 mutable_this.fCapacity = fUsed;
100 mutable_this.fExternal = buffer; 100 mutable_this.fExternal = buffer;
101 } 101 }
102 mutable_this.fSnapshot.reset(SkData::NewFromMalloc(buffer, fUsed)); 102 mutable_this.fSnapshot.reset(SkData::NewFromMalloc(buffer, fUsed));
103 } 103 }
104 return SkRef(fSnapshot.get()); // Take an extra ref for the caller. 104 return SkRef(fSnapshot.get()); // Take an extra ref for the caller.
105 } 105 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698