Skip to content

Commit

Permalink
Cleanup: Integer overflows, divide-by-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Oct 30, 2018
1 parent 6d28b6a commit a8a3649
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 3 additions & 3 deletions doomsday/apps/client/src/resource/hq2x.cpp
Expand Up @@ -253,9 +253,9 @@ void GL_InitSmartFilterHQ2x(void)
r = i << 3;
g = j << 2;
b = k << 3;
y = (uint32_t)( 0.299*r + 0.587*g + 0.114*b);
u = (uint32_t)(-0.169*r - 0.331*g + 0.5 *b) + 128;
v = (uint32_t)( 0.5 *r - 0.419*g - 0.081*b) + 128;
y = (uint32_t) de::clamp(0.0, ( 0.299*r + 0.587*g + 0.114*b), 255.0);
u = (uint32_t) de::clamp(0.0, (-0.169*r - 0.331*g + 0.5 *b) + 128, 255.0);
v = (uint32_t) de::clamp(0.0, ( 0.5 *r - 0.419*g - 0.081*b) + 128, 255.0);
lutBGR888toYUV888[BGR565_PACK(k, j, i)] = YUV888_PACK(y, u, v);
}
}
Expand Down
13 changes: 9 additions & 4 deletions doomsday/sdk/libappfw/src/widgets/scrollareawidget.cpp
Expand Up @@ -143,12 +143,17 @@ DENG_GUI_PIMPL(ScrollAreaWidget), public Lockable
Vector2i const viewSize = self().viewportSize();
if (viewSize == Vector2i()) return RectanglefPair();

auto const &margins = self().margins();

int const indHeight = de::clamp(
const auto &margins = self().margins();
const float contentHeight = float(contentRule.height().value());
int indHeight = 0;

if (contentHeight > 0)
{
indHeight = de::clamp(
margins.height().valuei(),
int(float(viewSize.y * viewSize.y) / float(contentRule.height().value())),
int(float(viewSize.y * viewSize.y) / contentHeight),
viewSize.y / 2);
}

float indPos = self().scrollPositionY().value() / self().maximumScrollY().value();
if (origin == Top) indPos = 1 - indPos;
Expand Down

0 comments on commit a8a3649

Please sign in to comment.