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

Unified Diff: util/mac/xattr.cc

Issue 1283243004: ubsan: Don’t call v[0] on empty vectors (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 4 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 | « snapshot/minidump/process_snapshot_minidump.cc ('k') | util/mach/child_port_handshake.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mac/xattr.cc
diff --git a/util/mac/xattr.cc b/util/mac/xattr.cc
index 54a8a09aac208615dcfa4f7cfecca3e7f794ce11..cb72e06e736757a291038f8ad9328cb3149baa9f 100644
--- a/util/mac/xattr.cc
+++ b/util/mac/xattr.cc
@@ -41,14 +41,16 @@ XattrStatus ReadXattr(const base::FilePath& file,
// Resize the buffer and read into it.
value->resize(buffer_size);
- ssize_t bytes_read = getxattr(file.value().c_str(), name.data(),
- &(*value)[0], value->size(),
- 0, 0);
- if (bytes_read < 0) {
- PLOG(ERROR) << "getxattr " << name << " on file " << file.value();
- return XattrStatus::kOtherError;
+ if (!value->empty()) {
+ ssize_t bytes_read = getxattr(file.value().c_str(), name.data(),
+ &(*value)[0], value->size(),
+ 0, 0);
+ if (bytes_read < 0) {
+ PLOG(ERROR) << "getxattr " << name << " on file " << file.value();
+ return XattrStatus::kOtherError;
+ }
+ DCHECK_EQ(bytes_read, buffer_size);
}
- DCHECK_EQ(bytes_read, buffer_size);
return XattrStatus::kOK;
}
« no previous file with comments | « snapshot/minidump/process_snapshot_minidump.cc ('k') | util/mach/child_port_handshake.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698