From e08ad44d0cf60b2bca38df81cad9447364c6a722 Mon Sep 17 00:00:00 2001 From: miker Date: Sat, 28 Apr 2007 23:46:02 +0000 Subject: [PATCH] Avoiding memory leaks in string opperations - patch provided by Scott McKellar - http://list.georgialibraries.org/pipermail/open-ils-dev/2007-April/000724.html git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@864 9efc2488-bf62-4759-914b-345cdb29e865 --- src/utils/utils.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/utils/utils.c b/src/utils/utils.c index a226cab..bdeaa96 100644 --- a/src/utils/utils.c +++ b/src/utils/utils.c @@ -1,7 +1,5 @@ /* Copyright (C) 2005 Georgia Public Library Service -Bill Erickson -Mike Rylander This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -290,6 +288,7 @@ char* uescape( const char* string, int size, int full_escape ) { buffer_fadd(buf, "\\u%04x", c); } else { + buffer_free(buf); return NULL; } @@ -370,13 +369,14 @@ int daemonize() { } } + +/* Return 1 if the string represents an integer, */ +/* as recognized by strtol(); Otherwise return 0. */ + int stringisnum(char* s) { - char* w = (char*) malloc(strlen(s) * sizeof(char*)); - bzero(w, strlen(s)); + char* w; strtol(s, &w, 10); - if(strlen(w) > 0) - return 0; - return 1; + return *w ? 0 : 1; } -- 2.43.2