diff options
author | Juli Mallett <jmallett@FreeBSD.org> | 2002-06-20 06:00:51 +0000 |
---|---|---|
committer | Juli Mallett <jmallett@FreeBSD.org> | 2002-06-20 06:00:51 +0000 |
commit | 6953dff37c2b4b4afd29da68623434df0300d3e4 (patch) | |
tree | 59eafe1456b306b1a32759a27249f24c4ad2222a /bin | |
parent | d7b8563d55f3b6ddd6a354a38e188be67d59e0ca (diff) | |
download | src-6953dff37c2b4b4afd29da68623434df0300d3e4.tar.gz src-6953dff37c2b4b4afd29da68623434df0300d3e4.zip |
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
Notes
Notes:
svn path=/head/; revision=98468
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rcp/extern.h | 2 | ||||
-rw-r--r-- | bin/rcp/rcp.c | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/bin/rcp/extern.h b/bin/rcp/extern.h index a07c3a6730e9..ebd2bebe1034 100644 --- a/bin/rcp/extern.h +++ b/bin/rcp/extern.h @@ -35,7 +35,7 @@ */ typedef struct { - int cnt; + size_t cnt; char *buf; } BUF; diff --git a/bin/rcp/rcp.c b/bin/rcp/rcp.c index 8f0a01d4c62c..b34506df2205 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); |