From: Jim Meyering Date: Sun, 30 Nov 1997 10:24:41 +0000 (+0000) Subject: (savedir): Check for size zero before invoking X-Git-Tag: TEXTUTILS-1_22c~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dcd4c05dfaeac27ea1ae101ccc3f47a9483a0fc5;p=thirdparty%2Fcoreutils.git (savedir): Check for size zero before invoking malloc; this can occur if st_size arg overflows on conversion to unsigned int. All callers now cast st_size arg to unsigned int. --- diff --git a/lib/savedir.c b/lib/savedir.c index 76634eef4e..4c07bffc29 100644 --- a/lib/savedir.c +++ b/lib/savedir.c @@ -87,7 +87,7 @@ savedir (dir, name_size) if (dirp == NULL) return NULL; - name_space = (char *) malloc (name_size); + name_space = (char *) malloc (name_size ? name_size : 1); if (name_space == NULL) { closedir (dirp);