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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/path.cc

Issue 1018393007: [NaCl SDK] nacl_io: Fix bug in Path::Range introduced in recent change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add additional tests for values completely outside the range Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/path_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/path.h" 5 #include "nacl_io/path.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 #include <string> 10 #include <string>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 if (slashes == start) 163 if (slashes == start)
164 pstart = p + 1; 164 pstart = p + 1;
165 165
166 if (slashes == end) { 166 if (slashes == end) {
167 pend = p; 167 pend = p;
168 break; 168 break;
169 } 169 }
170 } 170 }
171 } 171 }
172 172
173 if (pstart > pend) 173 if (slashes < start || pstart > pend)
174 return std::string(); 174 return std::string();
175 175
176 return std::string(pstart, pend - pstart); 176 return std::string(pstart, pend - pstart);
177 } 177 }
178 178
179 void Path::Normalize() { 179 void Path::Normalize() {
180 char* outp = &path_[0]; 180 char* outp = &path_[0];
181 const char* start = outp; 181 const char* start = outp;
182 const char* part_start = start; 182 const char* part_start = start;
183 const char* next_slash; 183 const char* next_slash;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 bool Path::operator==(const Path& other) { 264 bool Path::operator==(const Path& other) {
265 return len_ == other.len_ && strncmp(path_, other.path_, len_) == 0; 265 return len_ == other.len_ && strncmp(path_, other.path_, len_) == 0;
266 } 266 }
267 267
268 bool Path::operator!=(const Path& other) { 268 bool Path::operator!=(const Path& other) {
269 return !operator==(other); 269 return !operator==(other);
270 } 270 }
271 271
272 } // namespace nacl_io 272 } // namespace nacl_io
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/tests/nacl_io_test/path_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698