diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-02 20:28:31 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-02 20:28:31 +0000 |
commit | fd59d1200073604c0a5dafe14edbb6f3833e1c3d (patch) | |
tree | 3008160b02990b6a92b6e41facb627c7e22ca5d4 /src | |
parent | 8dcf114db9762c02d217beba6e29dffa4e92d298 (diff) |
change NewWithCString to allocate room for the terminating NULL, so the data
can be treated as a cstring (duh).
git-svn-id: http://skia.googlecode.com/svn/trunk@4430 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkData.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp index 2653f327c0..496d599379 100644 --- a/src/core/SkData.cpp +++ b/src/core/SkData.cpp @@ -112,10 +112,13 @@ SkData* SkData::NewSubset(const SkData* src, size_t offset, size_t length) { } SkData* SkData::NewWithCString(const char cstr[]) { - if (NULL == cstr || 0 == cstr[0]) { - return NewEmpty(); + size_t size; + if (NULL == cstr) { + cstr = ""; + size = 1; } else { - return NewWithCopy(cstr, strlen(cstr)); + size = strlen(cstr) + 1; } + return NewWithCopy(cstr, size); } |