- Avoid division by zero in TRACKBAR_GetTicPos

- Manage negative range TRACKBAR_DrawOneTic
This commit is contained in:
Stephan BEUZE 2003-08-05 18:25:26 +00:00 committed by Alexandre Julliard
parent 2123c1374a
commit 767070203d
1 changed files with 2 additions and 1 deletions

View File

@ -442,7 +442,7 @@ TRACKBAR_DrawOneTic (TRACKBAR_INFO *infoPtr, HDC hdc, LONG ticPos, int flags)
} }
range = infoPtr->lRangeMax - infoPtr->lRangeMin; range = infoPtr->lRangeMax - infoPtr->lRangeMin;
if (range == 0) if (range <= 0)
range = 1; /* to avoid division by zero */ range = 1; /* to avoid division by zero */
if (flags & TIC_SELECTIONMARK) { if (flags & TIC_SELECTIONMARK) {
@ -966,6 +966,7 @@ TRACKBAR_GetTicPos (TRACKBAR_INFO *infoPtr, INT iTic)
tic = TRACKBAR_GetTic (infoPtr, iTic); tic = TRACKBAR_GetTic (infoPtr, iTic);
range = infoPtr->lRangeMax - infoPtr->lRangeMin; range = infoPtr->lRangeMax - infoPtr->lRangeMin;
if (range <= 0) range = 1;
width = infoPtr->rcChannel.right - infoPtr->rcChannel.left; width = infoPtr->rcChannel.right - infoPtr->rcChannel.left;
pos = infoPtr->rcChannel.left + (width * tic) / range; pos = infoPtr->rcChannel.left + (width * tic) / range;