[PATCH] D63788: llvm-c-test avoid calling malloc(0)

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 08:09:10 PDT 2019


hubert.reinterpretcast added a comment.

To preserve exercising of the list getter when the count is zero, I suggest:

  int AttrCount = /*...*/;
  LLVMAttributeRef *Attrs = 0;
  if (AttrCount) {
    Attrs = /*...*/;
    assert(Attrs);
  }
  LLVMGet/*...*/;
  free(Attrs);

Even on systems where `malloc(0)` does not return a null pointer, the getter functions could not have safely accessed an object via said pointer.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63788/new/

https://reviews.llvm.org/D63788





More information about the llvm-commits mailing list