Skip to content

Commit

Permalink
Fix alignment issue with heap_string
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Oct 12, 2023
1 parent f361a43 commit ba308e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/jsoncons/detail/heap_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace detail {
std::size_t len = aligned_size(length*sizeof(char_type));

std::size_t align = alignof(storage_type);
std::size_t mem_len = align-1+len;
std::size_t mem_len = (align-1)+len;

byte_allocator_type byte_alloc(alloc);
byte_pointer ptr = byte_alloc.allocate(mem_len);
Expand Down Expand Up @@ -170,7 +170,7 @@ namespace detail {

char* p = q - ptr->offset_;

std::size_t mem_size = aligned_size(ptr->length_*sizeof(char_type));
std::size_t mem_size = (alignof(storage_type)-1)+ aligned_size(ptr->length_*sizeof(char_type));
byte_allocator_type byte_alloc(ptr->get_allocator());
byte_alloc.deallocate(p,mem_size + ptr->offset_);
}
Expand Down

0 comments on commit ba308e5

Please sign in to comment.