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

Unified Diff: src/runtime.cc

Issue 433463002: Avoid calling memchr with a zero range as this is undefined behavior. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/string-search.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 518e96a99bfc0c1cf6f636793a5784d5e0373a5a..f6abd93b605df5a2194278d3ed61dafa229af293 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -3603,7 +3603,7 @@ void FindAsciiStringIndices(Vector<const uint8_t> subject,
const uint8_t* subject_start = subject.start();
const uint8_t* subject_end = subject_start + subject.length();
const uint8_t* pos = subject_start;
- while (limit > 0) {
+ while ((limit > 0) && (subject_end > pos)) {
pos = reinterpret_cast<const uint8_t*>(
memchr(pos, pattern, subject_end - pos));
if (pos == NULL) return;
« no previous file with comments | « no previous file | src/string-search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698