From: Roman Bogorodskiy Date: Sat, 21 Jun 2014 15:24:04 +0000 (+0400) Subject: Fix closedir usage in virNumaGetPages X-Git-Tag: v1.2.6-rc1~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a82ef92bec219ecdbf9c033db16a606caa5daab;p=thirdparty%2Flibvirt.git Fix closedir usage in virNumaGetPages virNumaGetPages calls closedir(dir) in cleanup and dir could be NULL if we jump there from the failed opendir() call. While it's not harmful on Linux, FreeBSD libc crashes [1], so make sure that dir is not NULL before calling closedir. 1: http://lists.freebsd.org/pipermail/freebsd-standards/2014-January/002704.html --- diff --git a/src/util/virnuma.c b/src/util/virnuma.c index f6354c9d89..27b6ecb9a7 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -843,7 +843,8 @@ virNumaGetPages(int node, VIR_FREE(tmp_free); VIR_FREE(tmp_avail); VIR_FREE(tmp_size); - closedir(dir); + if (dir) + closedir(dir); VIR_FREE(path); return ret; }