Subject: | Extra null termination in quote.c |
In quote.c dequote_bytea() is a function that has changed a lot with
each release of DBD::Pg. In version 1.49 it has a memory leak (loosing
a buffer it allocated). Past 1.49 it null terminates the buffer in a
curious way:
void dequote_bytea(char *string, STRLEN *retlen, int estring)
{
...
*result = '\0';
return;
}
Curious, because the result of BYTEA decode is NOT null terminated.
Nobody should be treating that result as a null terminated string.
--------------------------------------------------------------------
This is a patch against 1.49 (the last in the 1.XX series) for the
memory leak:
# diff quote.c.old quote.c
308,310c308,309
< New(0, result, strlen((char *)string)+1, unsigned char);
<
< result = string;
---
Show quoted text
> /* New(0, result, strlen((char *)string)+1, unsigned char); */
> result = string; /* Dequote by chasing in supplied buffer */
336,338c335,339
< result = '\0';
< Renew(result, (*retlen), unsigned char);
< string = result - (*retlen);
---
Show quoted text> /* result = '\0'; */
> /* Renew(result, (*retlen), unsigned char); */
> /* string = result - (*retlen); */
>
> *result = '\0'; /* Wrong, as BYTEA is not null terminated, but this
matches 2.12.0 code */