case vSymlink:
if (v->size > symlink_size) {
if (symlink_buf)
- symlink_buf = realloc(symlink_buf, v->size + 1);
- else
- symlink_buf = (char *)malloc(v->size + 1);
+ free(symlink_buf);
+ symlink_buf = (char *)malloc(v->size + 1);
symlink_size = symlink_buf ? v->size : 0;
}
if (symlink_buf) {
int fast)
{
vhash_ent *vhe;
- char *name, *path = 0, fastbuf[12];
+ char *name, *path = 0, *oldpath = 0, fastbuf[12];
char *x, *y;
afs_uint32 parent, r;
int nl, pl = 0;
nl = strlen(name);
if (path) {
+ oldpath = path;
path = realloc(path, nl + pl + 2);
if (!path) {
+ free(oldpath);
if (phi->p->cb_error)
(phi->p->cb_error) (ENOMEM, 1, phi->p->err_refcon,
"No memory for pathname of vnode 1");
ReadString(XFILE * X, unsigned char **val)
{
static unsigned char buf[BUFSIZE];
- unsigned char *result = 0;
+ unsigned char *result = NULL, *old_result = NULL;
afs_uint32 r;
int i, l = 0;
break;
}
/* iff we found a null, i < BUFSIZE and buf[i] holds the NUL */
- if (result)
- result = realloc(result, l + i + 1);
- else
+ if (result) {
+ old_result = result;
+ result = realloc(old_result, l + i + 1);
+ if (!result) /* realloc failed, manually free old mem */
+ free(old_result);
+ } else
result = (unsigned char *)malloc(i + 1);
if (!result)
return ENOMEM;