割り当てるメモリーの不足

割り当てられたメモリーのサイズが、そのメモリーが割り当てられるポインターのポイント先のサイズよりも小さいです。

通常、このエラーは計算されたサイズが異なる場合に発生し、 境界違反を引き起こします。

ID

問題箇所

説明

1

割り当てサイト

メモリーが割り当てられた場所

          
#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;
}

        

© 2010 Intel Corporation. 無断での引用、転載を禁じます。