From f49002f4f645a3830346fc6d790ec32a2d43a4c2 Mon Sep 17 00:00:00 2001 From: jmallett Date: Thu, 20 Jun 2002 06:00:51 +0000 Subject: Use size_t consistently and complete some uncompleted code resulting in a memory leak by assigning and freeing a variable appropriately as well as keeping track of the amount of allocated ram properly. MFC after: 1 month --- bin/rcp/rcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin/rcp/rcp.c') diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index 8f0a01d..b34506d 100644 --- a/bin/rcp/rcp.c +++ b/bin/rcp/rcp.c @@ -670,14 +670,17 @@ sink(int argc, char *argv[]) if (*cp++ != ' ') SCREWUP("size not delimited"); if (targisdir) { - static char *namebuf; - static int cursize; + static char *namebuf = NULL; + static size_t cursize; size_t need; need = strlen(targ) + strlen(cp) + 250; if (need > cursize) { + if (namebuf != NULL) + free(namebuf); if (!(namebuf = malloc(need))) run_err("%s", strerror(errno)); + cursize = need; } (void)snprintf(namebuf, need, "%s%s%s", targ, *targ ? "/" : "", cp); -- cgit v1.1