Fossil SCM

Fix a potential division-by-zero in the file browser.

drh 2011-10-31 17:54 trunk
Commit 4d408219bdd62db86fd03cc5aeeb1786a9ac77d4
1 file changed +1
--- src/browse.c
+++ src/browse.c
@@ -249,10 +249,11 @@
249249
/* Generate a multi-column table listing the contents of zD[]
250250
** directory.
251251
*/
252252
mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
253253
cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/");
254
+ if( mxLen<12 ) mxLen = 12;
254255
nCol = 100/mxLen;
255256
if( nCol<1 ) nCol = 1;
256257
if( nCol>5 ) nCol = 5;
257258
nRow = (cnt+nCol-1)/nCol;
258259
db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/");
259260
--- src/browse.c
+++ src/browse.c
@@ -249,10 +249,11 @@
249 /* Generate a multi-column table listing the contents of zD[]
250 ** directory.
251 */
252 mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
253 cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/");
 
254 nCol = 100/mxLen;
255 if( nCol<1 ) nCol = 1;
256 if( nCol>5 ) nCol = 5;
257 nRow = (cnt+nCol-1)/nCol;
258 db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/");
259
--- src/browse.c
+++ src/browse.c
@@ -249,10 +249,11 @@
249 /* Generate a multi-column table listing the contents of zD[]
250 ** directory.
251 */
252 mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
253 cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/");
254 if( mxLen<12 ) mxLen = 12;
255 nCol = 100/mxLen;
256 if( nCol<1 ) nCol = 1;
257 if( nCol>5 ) nCol = 5;
258 nRow = (cnt+nCol-1)/nCol;
259 db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/");
260

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button