Is it secure to use malloc?

前端 未结 12 852
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-05 04:18

Somebody told me that allocating with malloc is not secure anymore, I\'m not a C/C++ guru but I\'ve made some stuff with malloc and C/C++. Does anyone know about what risks

12条回答
  •  死守一世寂寞
    2021-01-05 05:08

    What he maybe wanted to warn you is about pointers usage. Yes, that will cause problems if you don't understand how it works. Otherwise, ask what your friend meant, or ask him for a reference that proof his affirmation.

    Saying that malloc is not safe is like saying "don't use system X because it's insecure".

    Until that, use malloc in C, and new in C++. If you use malloc in C++, people will look mad at you, but that's fine in very specific occasions.

提交回复
热议问题