summaryrefslogtreecommitdiff
path: root/libs/hwui/PathParser.cpp
diff options
context:
space:
mode:
authorDoris Liu <tianliu@google.com>2016-04-12 11:06:23 -0700
committerDoris Liu <tianliu@google.com>2016-04-12 21:38:07 +0000
commitb35da390601e3c24e777d72daacd8dbeb4d1d9c4 (patch)
tree5949f592804c952b814cda6d154ab91eff2d864e /libs/hwui/PathParser.cpp
parentd92e5c314e1a3ffa0bc6daf43e4e9cec2521d217 (diff)
Allow leading spaces in path string (to keep behavior consistent)
Bug: 28132454 Change-Id: Iee799c13a85738db3d6940aca0fe917f284fa651
Diffstat (limited to 'libs/hwui/PathParser.cpp')
-rw-r--r--libs/hwui/PathParser.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/hwui/PathParser.cpp b/libs/hwui/PathParser.cpp
index 7e85333ef36b..2179f146115a 100644
--- a/libs/hwui/PathParser.cpp
+++ b/libs/hwui/PathParser.cpp
@@ -162,7 +162,7 @@ bool PathParser::isVerbValid(char verb) {
|| verb == 's' || verb == 't' || verb == 'v' || verb == 'z';
}
-void PathParser::getPathDataFromString(PathData* data, ParseResult* result,
+void PathParser::getPathDataFromAsciiString(PathData* data, ParseResult* result,
const char* pathStr, size_t strLen) {
if (pathStr == NULL) {
result->failureOccurred = true;
@@ -171,7 +171,16 @@ void PathParser::getPathDataFromString(PathData* data, ParseResult* result,
}
size_t start = 0;
- size_t end = 1;
+ // Skip leading spaces.
+ while (isspace(pathStr[start]) && start < strLen) {
+ start++;
+ }
+ if (start == strLen) {
+ result->failureOccurred = true;
+ result->failureMessage = "Path string cannot be empty.";
+ return;
+ }
+ size_t end = start + 1;
while (end < strLen) {
end = nextStart(pathStr, strLen, end);
@@ -226,9 +235,9 @@ void PathParser::dump(const PathData& data) {
ALOGD("points are : %s", os.str().c_str());
}
-void PathParser::parseStringForSkPath(SkPath* skPath, ParseResult* result, const char* pathStr, size_t strLen) {
+void PathParser::parseAsciiStringForSkPath(SkPath* skPath, ParseResult* result, const char* pathStr, size_t strLen) {
PathData pathData;
- getPathDataFromString(&pathData, result, pathStr, strLen);
+ getPathDataFromAsciiString(&pathData, result, pathStr, strLen);
if (result->failureOccurred) {
return;
}