summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-26 07:43:22 +0000
committerGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-26 07:43:22 +0000
commitc0f8aa9f1feb6cdf6001409174fef0c8372614a2 (patch)
treeee4914e38d270069d500de62bdaae948f18d46fa
parent750e9b32aa9c6d245f418f8fecfc37cba879e42e (diff)
Plugged some memory leaks.
-rw-r--r--lib/ZNewLocU.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/ZNewLocU.c b/lib/ZNewLocU.c
index 59c6fbd..3361aba 100644
--- a/lib/ZNewLocU.c
+++ b/lib/ZNewLocU.c
@@ -104,6 +104,7 @@ Code_t ZNewLocateUser(user, nlocs, auth)
if (retnotice.z_kind == SERVACK &&
!strcmp(retnotice.z_opcode,LOCATE_LOCATE)) {
ack = 1;
+ ZFreeNotice (&retnotice);
continue;
}
@@ -125,23 +126,28 @@ Code_t ZNewLocateUser(user, nlocs, auth)
__locate_list = (ZLocations_t *)malloc((unsigned)__locate_num*
sizeof(ZLocations_t));
- if (!__locate_list)
+ if (!__locate_list) {
+ ZFreeNotice (&retnotice);
return (ENOMEM);
+ }
for (ptr=retnotice.z_message, i=0;i<__locate_num;i++) {
__locate_list[i].host = malloc((unsigned)strlen(ptr)+1);
- if (!__locate_list[i].host)
+ if (!__locate_list[i].host) {
+ nomem:
+ ZFreeNotice (&retnotice);
return (ENOMEM);
+ }
(void) strcpy(__locate_list[i].host, ptr);
ptr += strlen(ptr)+1;
__locate_list[i].time = malloc((unsigned)strlen(ptr)+1);
if (!__locate_list[i].time)
- return (ENOMEM);
+ goto nomem;
(void) strcpy(__locate_list[i].time, ptr);
ptr += strlen(ptr)+1;
__locate_list[i].tty = malloc((unsigned)strlen(ptr)+1);
if (!__locate_list[i].tty)
- return (ENOMEM);
+ goto nomem;
(void) strcpy(__locate_list[i].tty, ptr);
ptr += strlen(ptr)+1;
}