summaryrefslogtreecommitdiff
path: root/base/HidlSupport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'base/HidlSupport.cpp')
-rw-r--r--base/HidlSupport.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index af805b9..78faa2f 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -217,6 +217,14 @@ void hidl_string::copyFrom(const char *data, size_t size) {
if (size >= UINT32_MAX) {
LOG(FATAL) << "string size can't exceed 2^32 bytes: " << size;
}
+
+ if (size == 0) {
+ mBuffer = kEmptyString;
+ mSize = 0;
+ mOwnsBuffer = false;
+ return;
+ }
+
char *buf = (char *)malloc(size + 1);
memcpy(buf, data, size);
buf[size] = '\0';