![hi! from what I understand(first pic) , we couldn't write *y = 13; because we did not use malloc to allocate memory to y before trying to pass 13 into the memory hi! from what I understand(first pic) , we couldn't write *y = 13; because we did not use malloc to allocate memory to y before trying to pass 13 into the memory](https://preview.redd.it/g25y7yb3ui771.jpg?width=640&crop=smart&auto=webp&s=2c4fb8225ac28c61bfd2db14498be3b8a42b62e2)
hi! from what I understand(first pic) , we couldn't write *y = 13; because we did not use malloc to allocate memory to y before trying to pass 13 into the memory
![c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow](https://i.stack.imgur.com/RPvMj.png)
c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow
![c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow](https://i.stack.imgur.com/Gzy7Z.png)
c - Function that returns dynamically allocated string works once, then returns garbage values on subsequent calls (after free has been called) - Stack Overflow
![Dynamic generation of rather complex JSON - error of memory allocation for a string - Development Platforms - PlatformIO Community Dynamic generation of rather complex JSON - error of memory allocation for a string - Development Platforms - PlatformIO Community](https://community.platformio.org/uploads/default/original/2X/1/1f4591492ed97004edd7c659368c52f676ef4702.png)
Dynamic generation of rather complex JSON - error of memory allocation for a string - Development Platforms - PlatformIO Community
![c++ - Memory leak identified by valgrind involving use of malloc to return a string that was returned via a std::string - Stack Overflow c++ - Memory leak identified by valgrind involving use of malloc to return a string that was returned via a std::string - Stack Overflow](https://i.stack.imgur.com/LosSd.png)