Discussion
As soon as a pointer variable is freed, its value
Answer: D
Correct answer: remains the same
free releases the storage but does nothing to the pointer, which is passed by value. Its bits are unchanged, so it still holds the address of memory that no longer belongs to the program - a dangling pointer.
This is exactly what makes use-after-free so dangerous: the pointer looks valid, may still appear to work while the freed block is untouched, and fails unpredictably once the allocator reuses it. The conventional discipline is to set the pointer to NULL immediately after freeing, so that misuse fails loudly.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development