From: bapt Date: Sat, 7 Nov 2015 16:45:51 +0000 (+0000) Subject: Run memset only after having checked the return of malloc X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=397e26d13592a3d550c9feac0ec9761af4bd62b0;p=people%2Fliuw%2Ffreebsd.git Run memset only after having checked the return of malloc Submitted by: pluknet --- diff --git a/usr.bin/localedef/collate.c b/usr.bin/localedef/collate.c index 5a31a75bac5..3216d21dbce 100644 --- a/usr.bin/localedef/collate.c +++ b/usr.bin/localedef/collate.c @@ -1256,11 +1256,11 @@ dump_collate(void) */ RB_NUMNODES(collchar_t, collchars, &collchars, n); large = malloc(sizeof (collate_large_t) * n); - memset(large, 0, sizeof (collate_large_t) * n); if (large == NULL) { fprintf(stderr, "out of memory"); return; } + memset(large, 0, sizeof (collate_large_t) * n); i = 0; RB_FOREACH(cc, collchars, &collchars) {