Opened 3 years ago

Last modified 23 months ago

#13885 reopened defect

wxCharBuffer.extend(len) bugfix

Reported by: troelsk Owned by:
Priority: high Milestone: 2.8.13
Component: base Version: 2.8.x
Keywords: wxCharBuffer Cc:
Blocked By: Blocking:
Patch: yes

Description

wxCharBuffer.extend(len) makes room for the zero terminator.
But it does not set it to 0 as it should (as the corresponding ctor does), so you end up with a non-terminated string.

This bug exists in both trunk and wx28 branch!

Attachments (4)

charbuffer.patch download (1.1 KB) - added by troelsk 3 years ago.
Trunk
charbuffer28.patch download (751 bytes) - added by troelsk 3 years ago.
2.8 branch
changes.txt.wx28.patch download (345 bytes) - added by troelsk 2 years ago.
2.8 branch
charbuffer-trunk.patch download (2.0 KB) - added by troelsk 2 years ago.
Remove redundant termination code, in trunk

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by troelsk

Trunk

Changed 3 years ago by troelsk

2.8 branch

comment:1 Changed 3 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [70417]) Ensure wxCharTypeBuffer data is NUL-terminated after extend() call.

As wxCharTypeBuffer ctor taking the length NUL-terminates the buffer, it may
be expected that extend() does the same but it did not. Do add the NUL at the
end for consistency, even though it's not really needed for the existing code
using extend() in wxWidgets itself.

Closes #13885.

comment:2 Changed 3 years ago by troelsk

  • Milestone set to 2.8.13
  • Priority changed from normal to high
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.9-svn to 2.8.x

Changed 2 years ago by troelsk

2.8 branch

Changed 2 years ago by troelsk

Remove redundant termination code, in trunk

comment:3 Changed 2 years ago by troelsk

Added patch removing unnecessary termination code in trunk

comment:4 Changed 23 months ago by VZ

(In [73141]) Don't unnecessarily NUL-terminate wxCharBuffer contents.

wxCharBuffer already initializes the last byte of the buffer it allocates to 0
so there is no need to do it explicitly.

Also don't allocate an extra byte, wxCharBuffer already adds one to the length
passed to it for the trailing NUL.

See #13885.

Note: See TracTickets for help on using tickets.