浏览代码

remove an issue uncovered by clang analyzer

Julius Pfrommer 8 年之前
父节点
当前提交
f940c9660a
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/ua_types.c

+ 4 - 0
src/ua_types.c

@@ -178,6 +178,10 @@ UA_Guid UA_Guid_random(void) {
 
 /* ByteString */
 UA_StatusCode UA_ByteString_allocBuffer(UA_ByteString *bs, size_t length) {
+    if(length == 0) {
+        UA_ByteString_init(bs);
+        return UA_STATUSCODE_GOOD;
+    }
     if(!(bs->data = UA_malloc(length)))
         return UA_STATUSCODE_BADOUTOFMEMORY;
     bs->length = length;