Fix heap corruption#109
Conversation
|
Can you give a case it fails? How it fixes the issue? I tried setting small page sizes and it all works. Also I don't see the bug here. The idea is following if it is a long string allocate a separate page for it, otherwise use paged pool. |
|
I also rerun some cases with small buffer size with valgrind to see if anythonig shows up and it does not. Can you please explain the fix and what it fixes. |
|
The reason for size * 2 - is to prevent wasting too much memory for large strings. |
|
The problem is the case were the size is between page size and 2 * page size. It's too small to allocate an own page with the correct size ( > 2 * page size case). Then depending on the size it allocates a new page or uses an existing page. But since the size is > page size it always writes the string out of bounds because a page has a maximum size of page_size and that is smaller than size. |
|
Note that I don't know why it worked with CppCMS 1.2.1 (same code in string_map.h). But with CppCMS 2.0.1 we started experiencing problems in only one of our applications. I found the origin of the problem with Valgrind's memcheck. |
in the case where size is between page_size and 2 * page_size.