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

Unified Diff: third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp

Issue 405153002: Provide consistent behaviour for memchr(_,_,0) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 | « third_party/android_crazy_linker/src/src/crazy_linker_line_reader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp
index 104f609df48aac2c99608af67086ece4ed058007..713870bea6ccbe32af090136c51c8e14534f4f89 100644
--- a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp
@@ -56,10 +56,15 @@ bool ParseProcMapsLine(const char* line,
p++;
// find start and end of current token, and compute start of
- // next search.
+ // next search. The result of memchr(_,_,0) is undefined, treated as
+ // not-found.
const char* tok_start = p;
- const char* tok_end =
- static_cast<const char*>(memchr(p, separator, line_end - p));
+ const size_t range = line_end - p;
+ const char* tok_end;
+ if (range > 0)
+ tok_end = static_cast<const char*>(memchr(p, separator, range));
+ else
+ tok_end = NULL;
rmcilroy 2014/07/22 09:16:36 Optional suggestion - I'm not sure if the crazy li
if (!tok_end) {
tok_end = line_end;
p = line_end;
« no previous file with comments | « third_party/android_crazy_linker/src/src/crazy_linker_line_reader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698