summaryrefslogtreecommitdiff
path: root/source3/web
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2001-08-08 16:54:16 +0000
committerSimo Sorce <idra@samba.org>2001-08-08 16:54:16 +0000
commit2f844bf447a98b802daa4b8d552ea4530e7f6108 (patch)
tree7beda0672e5fcc15125a7643d4d5fdef6f02b49e /source3/web
parent0897979a8b0976e03a84ccaf6a70cbaa62bbd195 (diff)
downloadsamba-2f844bf447a98b802daa4b8d552ea4530e7f6108.tar.gz
samba-2f844bf447a98b802daa4b8d552ea4530e7f6108.tar.bz2
samba-2f844bf447a98b802daa4b8d552ea4530e7f6108.zip
Change all realloc() statements to Realloc() (ecxept for tdb.c)
changed some code to exploit the fact that Realloc(NULL, size) == malloc(size) fixed some possible mem leaks, or seg faults. thanks to andreas moroder (mallocs not checked in client/client.c, client/smbumount.c) (This used to be commit 7f33c01688b825ab2fa9bbb2730bff4f2fa352be)
Diffstat (limited to 'source3/web')
-rw-r--r--source3/web/cgi.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/source3/web/cgi.c b/source3/web/cgi.c
index e47514904b..74e9969ff4 100644
--- a/source3/web/cgi.c
+++ b/source3/web/cgi.c
@@ -85,16 +85,23 @@ static void unescape(char *buf)
static char *grab_line(FILE *f, int *cl)
{
- char *ret;
+ char *ret = NULL;
int i = 0;
int len = 1024;
- ret = (char *)malloc(len);
- if (!ret) return NULL;
-
-
while ((*cl)) {
- int c = fgetc(f);
+ int c;
+
+ if (i == len) {
+ char *ret2;
+ if (len == 0) len = 1024;
+ else len *= 2;
+ ret2 = (char *)Realloc(ret, len*2);
+ if (!ret2) return ret;
+ ret = ret2;
+ }
+
+ c = fgetc(f);
(*cl)--;
if (c == EOF) {
@@ -108,13 +115,6 @@ static char *grab_line(FILE *f, int *cl)
ret[i++] = c;
- if (i == len-1) {
- char *ret2;
- ret2 = (char *)realloc(ret, len*2);
- if (!ret2) return ret;
- len *= 2;
- ret = ret2;
- }
}