[PATCH] D19085: [clang-analyzer] fix warnings emitted on compiler-rt code base

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 14 17:04:11 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL266388: Fix StaticAnalyzer complaints. NFC. (authored by gbiv).

Changed prior to commit:
  http://reviews.llvm.org/D19085?vs=53799&id=53817#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19085

Files:
  compiler-rt/trunk/lib/builtins/emutls.c

Index: compiler-rt/trunk/lib/builtins/emutls.c
===================================================================
--- compiler-rt/trunk/lib/builtins/emutls.c
+++ compiler-rt/trunk/lib/builtins/emutls.c
@@ -164,12 +164,14 @@
     emutls_address_array* array = pthread_getspecific(emutls_pthread_key);
     if (array == NULL) {
         uintptr_t new_size = emutls_new_data_array_size(index);
-        array = calloc(new_size + 1, sizeof(void*));
+        array = malloc(new_size * sizeof(void *) + sizeof(emutls_address_array));
+        if (array)
+            memset(array->data, 0, new_size * sizeof(void*));
         emutls_check_array_set_size(array, new_size);
     } else if (index > array->size) {
         uintptr_t orig_size = array->size;
         uintptr_t new_size = emutls_new_data_array_size(index);
-        array = realloc(array, (new_size + 1) * sizeof(void*));
+        array = realloc(array, new_size * sizeof(void *) + sizeof(emutls_address_array));
         if (array)
             memset(array->data + orig_size, 0,
                    (new_size - orig_size) * sizeof(void*));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19085.53817.patch
Type: text/x-patch
Size: 1100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160415/57a249d5/attachment.bin>


More information about the llvm-commits mailing list