From fc8bf1676927b85d48f2eff98931cedaf5ac2c43 Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Fri, 9 Oct 2015 13:49:48 +0200 Subject: [PATCH] Fixed a critical bug in the computation of the new number of lines of a column when truncating --- src/obidmscolumn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/obidmscolumn.c b/src/obidmscolumn.c index d55338b..efdb5ff 100644 --- a/src/obidmscolumn.c +++ b/src/obidmscolumn.c @@ -1046,7 +1046,7 @@ int obi_truncate_column_to_lines_used(OBIDMS_column_p column) // TODO is it nece // Compute the new line count = the number of lines used rounded to the nearest greater multiple of page size greater than 0 multiple = ceil((double) (ONE_IF_ZERO((column->header)->lines_used) * (column->header)->nb_elements_per_line * obi_sizeof((column->header)->data_type)) / (double) getpagesize()); - new_line_count = (int) multiple * getpagesize(); + new_line_count = floor((((int) multiple) * getpagesize()) / ((column->header)->nb_elements_per_line * obi_sizeof((column->header)->data_type))); // TODO is it safe to cast like this? // Check that it is actually greater than the current number of lines allocated in the file, otherwise no need to truncate if ((column->header)->line_count == new_line_count)