X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Freaddir.c;h=f8f95d269f88cb3a3de56d60910ced5dca842c4d;hb=0dd6c8c8442d4ff588f6dac2efab24d3409b0dec;hp=cea6fdd45c08351735f011f160e1e1a3747627d2;hpb=5186251f8f681f2ebb028423bb49a748861fd11e;p=libguestfs.git diff --git a/daemon/readdir.c b/daemon/readdir.c index cea6fdd..f8f95d2 100644 --- a/daemon/readdir.c +++ b/daemon/readdir.c @@ -1,5 +1,5 @@ /* libguestfs - the guestfsd daemon - * Copyright (C) 2009 Red Hat Inc. + * Copyright (C) 2009 Red Hat Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +37,7 @@ do_readdir (char *path) int i; NEED_ROOT (NULL); - ABS_PATH (path, NULL); + ABS_PATH (path, return NULL); ret = malloc (sizeof *ret); if (ret == NULL) { @@ -63,11 +63,13 @@ do_readdir (char *path) guestfs_int_dirent *p; p = realloc (ret->guestfs_int_dirent_list_val, - sizeof (guestfs_int_dirent) * (i+1)); + sizeof (guestfs_int_dirent) * (i+1)); v.name = strdup (d->d_name); if (!p || !v.name) { reply_with_perror ("allocate"); free (ret->guestfs_int_dirent_list_val); + free (p); + free (v.name); free (ret); closedir (dir); return NULL;