From: Jim Meyering Date: Sun, 30 Nov 1997 10:24:41 +0000 (+0000) Subject: (savedir): Check for size zero before invoking X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f82b55a4adcf7de3daff54cd1cffa0a4579277e;p=pspp (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);