CodeQL library for C/C++
codeql/cpp-all 0.12.11 (changelog, source)
Search

Predicate memberMayBeVarSize

Holds if v is a member variable of c that looks like it might be variable sized in practice. For example:

struct myStruct { // c
  int amount;
  char data[1]; // v
};

or

struct myStruct { // c
  int amount;
  char data[]; // v
};

This requires that v is an array of size 0 or 1, or that the array has no size.

Import path

import semmle.code.cpp.commons.Buffer
predicate memberMayBeVarSize(Class c, MemberVariable v)