[PATCH] D39121: [clang-tidy] Misplaced Operator in Strlen in Alloc

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 20 06:57:09 PDT 2017


martong added a comment.

Consider the use of a function pointer:

  void* malloc(int);
  int strlen(char*);
  auto fp = malloc;
  void bad_malloc(char *str) { char *c = (char *)fp(strlen(str + 1)); }

I think, the checker will not match in this case.

One might use allocation functions via a function pointer in case of more possible allocation strategies (e.g having a different strategy for a shared memory allocation).


https://reviews.llvm.org/D39121





More information about the cfe-commits mailing list