diff --git a/src/libafscp/afscp_dir.c b/src/libafscp/afscp_dir.c index 3ee49e982e..ad3638f5eb 100644 --- a/src/libafscp/afscp_dir.c +++ b/src/libafscp/afscp_dir.c @@ -509,6 +509,11 @@ afscp_HandleLink(struct afscp_venusfid *in, return in; } linkbuf = malloc(s->Length + 1); + if (linkbuf == NULL) { + afscp_errno = ENOMEM; + free(in); + return NULL; + } code = afscp_PRead(in, linkbuf, s->Length, 0); if (code < 0) { free(linkbuf); @@ -599,6 +604,7 @@ _ResolvePath(const struct afscp_venusfid *start, fidstack infids, if (fids == NULL) fids = fidstack_alloc(); if (fids == NULL) { + free(cwd); return NULL; } diff --git a/src/libafscp/afscp_dirops.c b/src/libafscp/afscp_dirops.c index 238535c397..3421e49885 100644 --- a/src/libafscp/afscp_dirops.c +++ b/src/libafscp/afscp_dirops.c @@ -41,7 +41,7 @@ afscp_CreateFile(const struct afscp_venusfid *dir, char *name, struct AFSStoreStatus *sst, struct afscp_venusfid **ret) { int code, i, j; - struct AFSFid df = dir->fid; + struct AFSFid df; struct afscp_volume *vol; struct AFSFetchStatus dfst, fst; struct AFSVolSync vs; @@ -56,6 +56,7 @@ afscp_CreateFile(const struct afscp_venusfid *dir, char *name, "afscp_CreateFile called with NULL args, cannot continue\n"); return -1; } + df = dir->fid; vol = afscp_VolumeById(dir->cell, dir->fid.Volume); if (vol == NULL) { afscp_errno = ENOENT;