Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Commented Issue: potential memory leaks in streams file I/O [189]

$
0
0
I still haven’t figured out in the non-error path who is responsible for deleting this buffer. One immediate problem is we allocate a buffer on the heap in many places like the following in fileio_winrt.cpp at line 328:

fInfo->m_buffer = new char[fInfo->m_bufsize*char_size];

Then in numerous places we mismatch a delete, for example look at the code just 4 lines above:

if ( fInfo->m_buffer != nullptr )
delete fInfo->m_buffer;

This is bad and I see this going on in lots of places.
Comments: This is in Windows specific code and on Windows with raw char data structure this will still be freed correctly. So there isn't a leak but this is still bad code.

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>