[llvm-dev] MallocAllocator returns nonnull?

<Alexander G. Riccio> via llvm-dev llvm-dev at lists.llvm.org
Sun Mar 6 11:19:29 PST 2016


The MallocAllocator Allocate function is defined as:

  LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size,
                                                size_t /*Alignment*/) {
    return malloc(Size);
  }

...but malloc can totally return NULL? What's up?

I assume this is intended to be an optimization/warning silencer? (i.e.
LLVM just normally doesn't handle OOM) ...but this can cause security
issues (via nullptr deref)?

On a related note, maybe Allocate should be marked as
LLVM_ATTRIBUTE_RETURNS_NOALIAS?

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio

<http://about.me/ariccio>
If left to my own devices, I will build more.
⁂
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160306/96fc39eb/attachment-0001.html>


More information about the llvm-dev mailing list