双malloc的行为自由 [英] malloc double free behaviour

查看:128
本文介绍了双malloc的行为自由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的malloc 的GNU手册页定义,当免费()使用同一指针调用两次(这是$ p $由 pviously分配的malloc())出现未定义的行为。

The GNU manual page for malloc defines that when free() called twice with the same pointer (that was previously allocated by malloc()) "undefined behaviour occurs".

什么样的​​行为是什么?结果
我在哪里可以找到这种类型的错误的更多信息?

What kind of behaviour is that?
Where can I find more Information about this kind of error?

推荐答案

未定义行为,只是意味着实现不需要处理任何特殊方式的情况;的任何的行为或结果被认为是正确的。

"Undefined behavior" simply means that the implementation isn't required to deal with the situation in any particular way; any behavior or result is considered "correct".

免费的-ing不止一次指针的结果是达到的malloc 的底层实现;其结果可能是一个崩溃和核心转储,也可能损坏的malloc 舞台(污损了未来分配/释放操作),或者它可能忽略双免费完全。

The result of free-ing a pointer more than once is up to the underlying implementation of malloc; the result could be a crash and core dump, or it could corrupt the malloc arena (fouling up future allocations/deallocations), or it could ignore the double free entirely.

这篇关于双malloc的行为自由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆