]> git.evergreen-ils.org Git - OpenSRF.git/commit
Patch from Scott McKellar:
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 17 Nov 2008 03:17:50 +0000 (03:17 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 17 Nov 2008 03:17:50 +0000 (03:17 +0000)
commitc5904a8e5afdcc24dd9d400c970ddb6db626bbfe
tree16d6650f9fee948d5171f47fb2f11c9a015b57a2
parent63670107c380893fc62be356d9700c23b7776c96
Patch from Scott McKellar:

This patch is mostly a couple of tweaks to the growing_buffer code, loosely
related to my previous patch to utils.h.  There is also a small tweak to
uescape().

1. in buffer_add() I replaced strcat() with strcpy() for appending the new
string.  Since we already know where the end of the old string is, we don't
need to ask strcat() to find it for us.

2. In buffer_reset(), the old code contains the following:

osrf_clearbuf( gb->buf, sizeof(gb->buf) );

The evident intent is to clear the buffer.  However sizeof(gb->buf) is not
the size of the buffer, it's the size of the pointer to the buffer.  We
were clearing only the first four bytes or so.  I changed the line to:

osrf_clearbuf( gb->buf, gb->size );

3. Also in buffer_reset(), I added a line to populate the first byte of
the buffer with a nul, to ensure that the length of the (empty) string matches the n_used member.

4. In uescape(), we were examining the contents of string[] without first
verifying that string was not NULL.  The result would be undefined
behavior if string were ever NULL.  I added a couple of lines to treat
a NULL pointer as if it were a pointer to an empty string.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1496 9efc2488-bf62-4759-914b-345cdb29e865
src/libopensrf/utils.c