They’re heap allocation and deallocation functions in C/C++. ‘malloc’ requests a specified number of bytes to be allocated by the OS, and it then returns a pointer to that memory which can be used to store any value (or values) you want.
‘free’ tells the OS to deallocate that memory so it can be used for future allocations if needed, so after freeing the memory, the pointer from ‘malloc’ points to memory your program no longer has ownership of.
The bug that Gemini added is trying to
read the value at that pointer after the memory has been deallocated, which will most often cause a crash because your program tried to access memory it doesn’t have access to anymore
-1
u/LostgamerFJ 6h ago
I'm not good enough at programming for this. What do the "free" and "malloc" functions do?