From: Matthias Andree Date: Thu, 13 Jan 2005 02:35:29 +0000 (+0100) Subject: Fix crash when /proc/acpi/ac_adapter/ is not present, for instance, X-Git-Tag: E2FSPROGS-1_36~62 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4b13704cbec7249ba223608143026142b8729318;p=tools%2Fe2fsprogs.git Fix crash when /proc/acpi/ac_adapter/ is not present, for instance, on pre-ACPI and non-Linux systems. --- diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog index 0fff501..fb48f11 100644 --- a/e2fsck/ChangeLog +++ b/e2fsck/ChangeLog @@ -1,3 +1,9 @@ +2005-01-13 Matthias Andree + + * unix.c: Do not call closedir if the handle is zero, to avoid + crashes when the /proc/acpi/ac_adapter directory is + missing, for instance on non-ACPI or non-Linux systems. + 2005-01-09 Theodore Ts'o * pass1b.c: As part of converting configure.in from using the diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 7e55f87..43a64b5 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -238,7 +238,8 @@ static int is_on_batt(void) return 1; } } - closedir(d); + if (d) + closedir(d); return 0; }