Check index before using

pull/3182/head
qarmin 2020-04-28 20:31:59 +02:00
parent bd5b7ecab9
commit 4dfdbbf171
1 changed files with 3 additions and 3 deletions

View File

@ -145,13 +145,13 @@ bool ParseDataURI(const char *const_uri, size_t uriLen, DataURI &out) {
size_t i = 5, j; size_t i = 5, j;
if (uri[i] != ';' && uri[i] != ',') { // has media type? if (uri[i] != ';' && uri[i] != ',') { // has media type?
uri[1] = char(i); uri[1] = char(i);
for (; uri[i] != ';' && uri[i] != ',' && i < uriLen; ++i) { for (;i < uriLen && uri[i] != ';' && uri[i] != ','; ++i) {
// nothing to do! // nothing to do!
} }
} }
while (uri[i] == ';' && i < uriLen) { while (i < uriLen && uri[i] == ';') {
uri[i++] = '\0'; uri[i++] = '\0';
for (j = i; uri[i] != ';' && uri[i] != ',' && i < uriLen; ++i) { for (j = i; i < uriLen && uri[i] != ';' && uri[i] != ','; ++i) {
// nothing to do! // nothing to do!
} }