Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider (sch jbop) (X_X)@==(Q_Q)@

...

Code Block
bgColor#ccccff
if (number > SIZE_MAX/sizeof(int)) {
   /* handle overflow */
  }
x = (int *)malloc(number * sizeof(int));
if (x == NULL) {
  /* Handle Allocation Error */
}
/* ... */
if (error_condition == 1) {
  /* Handle Error Condition*/
}
/* ... */
free(x);
x = NULL;  

Wiki Markup
Note that this solution checks for numeric overflow \[[INT32-C. Ensure that operations on signed integers do not result in overflow]\].

...

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

MEM31-C

3 ( high )

2 ( probable ) 2 (

medium )

P12

L1

Automated Detection

The LDRA tool suite V 7.6.0 is able to detect violations of this rule.

...