Chromium Code Reviews

Side by Side Diff: chrome/common/sqlite_utils.cc

Issue 2801017: sqlite_utils: don't dereference an empty vector. (Closed)
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « chrome/browser/sync/util/user_settings_unittest.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/common/sqlite_utils.h" 5 #include "chrome/common/sqlite_utils.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 305 matching lines...)
316 return sqlite3_db_handle(stmt_); 316 return sqlite3_db_handle(stmt_);
317 } 317 }
318 318
319 int SQLStatement::bind_parameter_count() { 319 int SQLStatement::bind_parameter_count() {
320 DCHECK(stmt_); 320 DCHECK(stmt_);
321 return sqlite3_bind_parameter_count(stmt_); 321 return sqlite3_bind_parameter_count(stmt_);
322 } 322 }
323 323
324 int SQLStatement::bind_blob(int index, std::vector<unsigned char>* blob) { 324 int SQLStatement::bind_blob(int index, std::vector<unsigned char>* blob) {
325 if (blob) { 325 if (blob) {
326 const void* value = &(*blob)[0]; 326 const void* value = blob->empty() ? NULL : &(*blob)[0];
327 int len = static_cast<int>(blob->size()); 327 int len = static_cast<int>(blob->size());
328 return bind_blob(index, value, len); 328 return bind_blob(index, value, len);
329 } else { 329 } else {
330 return bind_null(index); 330 return bind_null(index);
331 } 331 }
332 } 332 }
333 333
334 int SQLStatement::bind_blob(int index, const void* value, int value_len) { 334 int SQLStatement::bind_blob(int index, const void* value, int value_len) {
335 return bind_blob(index, value, value_len, SQLITE_TRANSIENT); 335 return bind_blob(index, value, value_len, SQLITE_TRANSIENT);
336 } 336 }
(...skipping 170 matching lines...)
507 return wstr; 507 return wstr;
508 } 508 }
509 509
510 #if defined(USE_SYSTEM_SQLITE) 510 #if defined(USE_SYSTEM_SQLITE)
511 // This function is a local change to sqlite3 which doesn't exist when one is 511 // This function is a local change to sqlite3 which doesn't exist when one is
512 // using the system sqlite library. Thus, we stub it out here. 512 // using the system sqlite library. Thus, we stub it out here.
513 int sqlite3Preload(sqlite3* db) { 513 int sqlite3Preload(sqlite3* db) {
514 return 0; 514 return 0;
515 } 515 }
516 #endif 516 #endif
OLDNEW
« no previous file with comments | « chrome/browser/sync/util/user_settings_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine