Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix one more memory size calculation. #185

Merged
merged 1 commit into from
Jan 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/msgpack/unpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,12 @@ inline void unpacker::expand_buffer(std::size_t size)
std::size_t next_size = m_initial_buffer_size; // include COUNTER_SIZE
std::size_t not_parsed = m_used - m_off;
while(next_size < size + not_parsed + COUNTER_SIZE) {
next_size *= 2;
std::size_t tmp_next_size = next_size * 2;
if (tmp_next_size <= next_size) {
next_size = size + not_parsed + COUNTER_SIZE;
break;
}
next_size = tmp_next_size;
}

char* tmp = static_cast<char*>(::malloc(next_size));
Expand Down