On Tue, 31 Mar 2009 00:01:17 +0100, John-Mark Bell wrote:
On Mon, 2009-03-30 at 18:10 +0000, netsurf(a)semichrome.net wrote:
> Author: chris_y
> Date: Mon Mar 30 13:10:16 2009
> New Revision: 7001
>
> URL:
http://source.netsurf-browser.org?rev=7001&view=rev
> Log:
> Stop URL bar losing characters on every refresh
>
> Modified:
> trunk/netsurf/desktop/browser.c
>
> Modified: trunk/netsurf/desktop/browser.c
> URL:
http://source.netsurf-browser.org/trunk/netsurf/desktop/browser.c?rev=700...
> ==============================================================================
> --- trunk/netsurf/desktop/browser.c (original)
> +++ trunk/netsurf/desktop/browser.c Mon Mar 30 13:10:16 2009
> @@ -1096,11 +1096,11 @@
> url_buf = malloc(len + 2 /* '#' + '\0' */);
> if (url_buf) {
> if (frag) {
> - snprintf(url_buf, len + 1, "%s#%s", url, frag);
> + snprintf(url_buf, len + 2, "%s#%s", url, frag);
> + *(url_buf + len + 2) = '\0';
Either I'm being stupid, or this now writes one byte past the end of the
buffer.
I had to think about it, but yes - you're right. Buffer of length
len+2 will have the last character at len+1 (as first character is at
0, not 1).
Fixed, thanks.
Chris