/* Allocate once, free twice. */
void f3()
{
char *p;
p = malloc(10);
...
free(p);
...
free(p);
}
/* Allocate zero times, free once. */
void f4()
{
char *p;
/* Note that p remains uninitialized here. */
free(p);
}
這些錯誤通常也不太嚴重。盡管 C 標準在這些情形中沒有定義具體行為,但典型的實現將忽略錯誤,或者快速而明確地對它們進行標記;總之,這些都是安全情形。
文章來源于領測軟件測試網 http://www.kjueaiud.com/