Insufficient memory allocation

The size of allocated memory is less than the size of the pointed-to type of the pointer to which it is assigned.

Usually, this error results from an incorrect size computation. This error often leads to a subsequent bounds violation.

ID

Observation

Description

1

Allocation site

The place the memory was allocated

Example

          
#include <stdlib.h>

typedef struct {
    int f1;
    int f2;
    int f3;
} s1;

typedef struct {
    int f1;
    int f2;
} s2;

int main(int argc, char **argv)
{
    s1 *p = (s1 *) malloc( sizeof(s2) ); // probably intended sizeof(s1)
    free(p);
    return 0;
}

        

Copyright © 2010, Intel Corporation. All rights reserved.