#452 slightly increase buffers when dealing with UTF8

puredata (385)

running Pd through valgrind [1] gives a number of "Invalid read" errors, as soon as you create an object and type a single letter (e.g. "f").
creating the object (by licking besides it), gives another number of "Invalid read" errors.

those errors suggest that memory outside the allocated buffer is accessed. it seems that all these errors are related to the UTF-8 code (since with utf-8 we might have to check multiple bytes).

the attached fix simply increases the allocated buffer slightly (more than what happens already), so the read can take place on safe grounds.

[1] like with $ valgrind --tool=memcheck --leak-check=full ./src/pd -noprefs -nrt -noaudio -stderr


  • Marvin Humphrey

    Marvin Humphrey - 2012-03-15

    The existing UTF-8 processing code assumes that strings are NUL-terminated and feels free to access that NUL byte beyond the buffer. However, the strings PD uses are always paired with a length, so it is possible to perform UTF-8 processing without going past the end of the buffer. That other patch gets rid of the overruns, and applying it should indeed clear the Valgrind errors that inspired both patches.

  • Miller Puckette

    Miller Puckette - 2012-06-22

    applied to 0.43-3 test

  • Miller Puckette

    Miller Puckette - 2012-06-22
    • status: open --> pending
  • IOhannes m zmölnig

    • status: pending --> closed-fixed


Cancel  Add attachments