[OPEN-ILS-DEV] PATCH: memory leaks in utils.c

Scott McKellar mck9 at swbell.net
Sat Apr 28 17:10:21 EDT 2007


I attach a patch to ILS/OpenSRF/src/utils/utils.c to fix two
memory leaks.

The first leak is in the uescape function.  When we encounter
an invalid UTF8 character we return immediately without
destroying the growing_buffer.  I added a call to buffer_free()
before the return.

The second is in the stringisnum function, and occurs on every 
call.  We allocate a buffer, fill it with binary zeros, and then
overwrite the pointer to it without ever using it for anything.

I removed the calls to malloc() and bzero().  I also replaced
the call to strlen() with an examination of the first character
of the buffer.  We don't really care how long the string is, we
just want to know whether it's empty.

In my posting on March 26 I proposed two other possible
replacements for this function.  One of them behaves
identically but is presumably more efficient.  The other
behaves slightly differently in that it recognizes when a number
is too big to be represented as a long.  Since I don't know what
the desired behavior is, I left the behavior alone.

---------------

Here is the DCO 1.1 as requested (Incidentally your link to it
needs to be fixed -- the OSDL material is moving to the Linux
Foundation).  I'm not sure what the rule is but I assume that this
verbiage is to be included with every patch submitted:

Developer’s Certificate of Origin 1.1 By making a contribution to this
project, I certify that:

(a) The contribution was created in whole or in part by me and I have
the right to submit it under the open source license indicated in the
file; or

(b) The contribution is based upon previous work that, to the best of
my knowledge, is covered under an appropriate open source license and I
have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under the
same open source license (unless I am permitted to submit under a
different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person
who certified (a), (b) or (c) and I have not modified it; and

(d) In the case of each of (a), (b), or (c), I understand and agree
that this project and the contribution are public and that a record of
the contribution (including all personal information I submit with it,
including my sign-off) is maintained indefinitely and may be
redistributed consistent with this project or the open source license
indicated in the file. 

Scott McKellar
http://home.swbell.net/mck9/aargh/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: utils_c_2.patch
Type: text/x-patch
Size: 780 bytes
Desc: 1107252440-utils_c_2.patch
Url : http://list.georgialibraries.org/pipermail/open-ils-dev/attachments/20070428/2485a212/utils_c_2.bin


More information about the Open-ils-dev mailing list