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; |
} |