From: Eric Bollengier Date: Tue, 19 Jan 2010 16:17:26 +0000 (+0100) Subject: Cleanup win32 compat code X-Git-Tag: Release-5.0.0~51 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=877ec618c5c26cb4b49b09897985b5d6b8841bc8;p=bacula%2Fbacula Cleanup win32 compat code --- diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index 0b806ce9de..1fc161e001 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -1161,6 +1161,7 @@ opendir(const char *path) { /* enough space for VSS !*/ int max_len = strlen(path) + MAX_PATH; + char *tspec = NULL; _dir *rval = NULL; if (path == NULL) { errno = ENOENT; @@ -1169,10 +1170,15 @@ opendir(const char *path) Dmsg1(100, "Opendir path=%s\n", path); rval = (_dir *)malloc(sizeof(_dir)); + if (!rval) { + goto err; + } memset (rval, 0, sizeof (_dir)); - if (rval == NULL) return NULL; - char *tspec = (char *)malloc(max_len); - if (tspec == NULL) return NULL; + + tspec = (char *)malloc(max_len); + if (!tspec) { + goto err; + } conv_unix_to_win32_path(path, tspec, max_len); Dmsg1(100, "win32 path=%s\n", tspec); @@ -1222,8 +1228,12 @@ opendir(const char *path) return (DIR *)rval; err: - free((void *)rval->spec); - free(rval); + if (rval) { + free(rval); + } + if (tspec) { + free(tspec); + } errno = b_errno_win32; return NULL; }