1. Home
  2. Computer Science MCQs
  3. C Programming
  4. What is the result of calling free twice on the same…

Added 30 Nov -0001

What is the result of calling free twice on the same pointer?

  1. The block is simply released again
  2. A compile-time error in every compiler
  3. The pointer is set to NULL for you
  4. Undefined behaviour and possible heap damage Correct answer

Correct answer

D. Undefined behaviour and possible heap damage

13 views

MCQSEXAM

Explanation

A double free corrupts allocator state, so the C standard leaves the behaviour undefined.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs