diff options
Diffstat (limited to 'lib/e2p')
-rw-r--r-- | lib/e2p/ChangeLog | 5 | ||||
-rw-r--r-- | lib/e2p/percent.c | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index 48834010..75e2cd3b 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,8 @@ +2006-09-29 Theodore Tso <tytso@mit.edu> + + * percent.c (e2p_percent): Fix bug which caused e2p_percent to + crash if the percentage was zero. + 2006-08-30 Theodore Tso <tytso@mit.edu> * percent.c (e2p_percent): Add a new function which accurate and diff --git a/lib/e2p/percent.c b/lib/e2p/percent.c index f4497b6f..b8c936df 100644 --- a/lib/e2p/percent.c +++ b/lib/e2p/percent.c @@ -19,6 +19,8 @@ unsigned int e2p_percent(int percent, unsigned int base) { unsigned int mask = ~((1 << (sizeof(unsigned int) - 1) * 8) - 1); + if (!percent) + return 0; if (100 % percent == 0) return base / (100 / percent); if (mask & base) |