How can malloc() cause a SIGSEGV?

前端 未结 6 1539
长情又很酷
长情又很酷 2021-01-02 12:09

I have an odd bug in my program, it appears to me that malloc() is causing a SIGSEGV, which as far as my understanding goes does not make any sense. I am using a library cal

6条回答
  •  旧巷少年郎
    2021-01-02 12:24

    The code is problematic. If malloc returns NULL, this case is not handled correctly in your code. You simply assume that memory has been allocated for you when it actually has not been. This can cause memory corruption.

提交回复
热议问题