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

Edited Issue: Mismatched new/delete in streams.h [112]

$
0
0
The memory buffers in Release/include/cpprest/streams.h deallocate with delete instead of delete[]. The result (at least on Linux) is memory corruption.

Here's the fix patch:
diff --git a/Release/include/cpprest/streams.h b/Release/include/cpprest/streams.h
index 21fe3eb..2b6f98f 100644
--- a/Release/include/cpprest/streams.h
+++ b/Release/include/cpprest/streams.h
@@ -251,7 +251,10 @@ namespace Concurrency { namespace streams
source.release(data, 0);
}

- std::shared_ptr<CharType> buf(new CharType[count]);
+ std::shared_ptr<CharType> buf(new CharType[count], [](CharType* buf)
+ {
+ delete [] buf;
+ });

auto post_write =
[buf](pplx::task<size_t> op)-> pplx::task<size_t>
@@ -723,7 +726,11 @@ namespace Concurrency { namespace streams
buffer.release(data, 0);
}

- std::shared_ptr<CharType> buf(new CharType[count]);
+ std::shared_ptr<CharType> buf(new CharType[count], [](CharType* buf)
+ {
+ delete [] buf;
+ });
+

auto post_write =
[buf](pplx::task<size_t> op) -> pplx::task<size_t>


Viewing all articles
Browse latest Browse all 4845

Trending Articles



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