Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This compliant solution ensures the size argument used to allocate vla is in a valid range (between 1 and a programmer-defined maximum); otherwise, it uses an algorithm that relies on dynamic memory allocation.:

Code Block
bgColor#ccccff
langc
enum { MAX_ARRAY = 1024 };

void func(size_t size) {
  if (0 < size && size < MAX_ARRAY) {
    int vla[size];
    /* ... */
  } else {
    /* Use dynamic allocation */
  }
}
/* ... */

...

Tool

Version

Checker

Description

Coverity6.5REVERSE_NEGATIVEFully Implemented
PRQA QA-C
Include Page
PRQA_V
PRQA_V
1051Partially implemented.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

Bibliography

 

...