aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-02 20:28:31 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-07-02 20:28:31 +0000
commitfd59d1200073604c0a5dafe14edbb6f3833e1c3d (patch)
tree3008160b02990b6a92b6e41facb627c7e22ca5d4 /src
parent8dcf114db9762c02d217beba6e29dffa4e92d298 (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.cpp9
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);
}