Comment 2 for bug 307652

Revision history for this message
Mark O'Donohue (mark-odonohue) wrote :

The buffer in editline.c
      STATIC char* read_redirected()

is 64 characters long, when it get to the end of 64 characters it does:

        if (p == end) {
            size += MEM_INC;
            p = line = realloc(line, size);
            end = p + size;
        }

So 'p' which is where it is writing the next character is set back to the start of the line, not left at the end. The attached patch, bumps p to next write position correctly.

        if (p == end) {
            int lengthSoFar = p - line;
            size += MEM_INC;
            line = realloc(line, size);
            p = line + lengthSoFar;
            end = line + size;
        }

Cheers - Mark