From d92a600ced45d79dfbc1a810d41c20c80f44de3a Mon Sep 17 00:00:00 2001 From: mfeemster Date: Mon, 15 Feb 2016 18:54:24 -0800 Subject: [PATCH] --Bug fixes -Crash when supersample minus final spatial filter width was negative. --- Source/Ember/Renderer.cpp | 4 +++- Source/Fractorium/Fractorium.cpp | 2 +- Source/Fractorium/Fractorium.h | 10 +++++----- Source/Fractorium/FractoriumInfo.cpp | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/Ember/Renderer.cpp b/Source/Ember/Renderer.cpp index f485f31..8b974a8 100644 --- a/Source/Ember/Renderer.cpp +++ b/Source/Ember/Renderer.cpp @@ -82,7 +82,9 @@ template void Renderer::ComputeBounds() { size_t maxDEFilterWidth = 0; - m_GutterWidth = ClampGte((m_SpatialFilter->FinalFilterWidth() - Supersample()) / 2, size_t(0)); + //Use type T to account for negative numbers which will occur with a larger supersample and smaller filter width. + //The final value will be of type size_t. + m_GutterWidth = size_t(ClampGte((T(m_SpatialFilter->FinalFilterWidth()) - T(Supersample())) / 2, 0)); //Check the size of the density estimation filter. //If the radius of the density estimation filter is greater than the diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index d89ae30..b9710bd 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -213,7 +213,7 @@ Fractorium::~Fractorium() void Fractorium::SetCoordinateStatus(int rasX, int rasY, float worldX, float worldY) { //Use sprintf rather than allocating and concatenating 6 QStrings for efficiency since this is called on every mouse move. - sprintf_s(m_CoordinateString, 128, "Window: %4d, %4d World: %2.2f, %2.2f", rasX, rasY, worldX, worldY); + sprintf_s(m_CoordinateString, sizeof(m_CoordinateString), "Window: %4d, %4d World: %2.2f, %2.2f", rasX, rasY, worldX, worldY); m_CoordinateStatusLabel->setText(QString(m_CoordinateString)); } diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index 364b32a..9503eca 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -488,12 +488,12 @@ private: QLabel* m_RenderStatusLabel; QLabel* m_CoordinateStatusLabel; FractoriumSettings* m_Settings; - char m_ULString[32]; - char m_URString[32]; - char m_LRString[32]; - char m_LLString[32]; + char m_ULString[64]; + char m_URString[64]; + char m_LRString[64]; + char m_LLString[64]; char m_WHString[64]; - char m_DEString[16]; + char m_DEString[64]; char m_CoordinateString[128]; QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor; QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon; diff --git a/Source/Fractorium/FractoriumInfo.cpp b/Source/Fractorium/FractoriumInfo.cpp index e59dd02..504bd0a 100644 --- a/Source/Fractorium/FractoriumInfo.cpp +++ b/Source/Fractorium/FractoriumInfo.cpp @@ -185,11 +185,11 @@ void Fractorium::UpdateHistogramBounds() { if (RendererBase* r = m_Controller->Renderer()) { - sprintf_s(m_ULString, 32, "UL: %3.3f, %3.3f", r->LowerLeftX(), r->UpperRightY());//These bounds include gutter padding. - sprintf_s(m_URString, 32, "UR: %3.3f, %3.3f", -r->LowerLeftX(), r->UpperRightY()); - sprintf_s(m_LRString, 32, "LR: %3.3f, %3.3f", -r->LowerLeftX(), r->LowerLeftY()); - sprintf_s(m_LLString, 32, "LL: %3.3f, %3.3f", r->LowerLeftX(), r->LowerLeftY()); - sprintf_s(m_WHString, 32, "W x H: %4lu x %4lu", r->SuperRasW(), r->SuperRasH()); + sprintf_s(m_ULString, sizeof(m_ULString), "UL: %3.3f, %3.3f", r->LowerLeftX(), r->UpperRightY());//These bounds include gutter padding. + sprintf_s(m_URString, sizeof(m_URString), "UR: %3.3f, %3.3f", -r->LowerLeftX(), r->UpperRightY()); + sprintf_s(m_LRString, sizeof(m_LRString), "LR: %3.3f, %3.3f", -r->LowerLeftX(), r->LowerLeftY()); + sprintf_s(m_LLString, sizeof(m_LLString), "LL: %3.3f, %3.3f", r->LowerLeftX(), r->LowerLeftY()); + sprintf_s(m_WHString, sizeof(m_WHString), "W x H: %4lu x %4lu", r->SuperRasW(), r->SuperRasH()); ui.InfoBoundsLabelUL->setText(QString(m_ULString)); ui.InfoBoundsLabelUR->setText(QString(m_URString)); ui.InfoBoundsLabelLR->setText(QString(m_LRString)); @@ -200,7 +200,7 @@ void Fractorium::UpdateHistogramBounds() if (r->GetDensityFilter()) { uint deWidth = (r->GetDensityFilter()->FilterWidth() * 2) + 1; - sprintf_s(m_DEString, 16, "%d x %d", deWidth, deWidth); + sprintf_s(m_DEString, sizeof(m_DEString), "%d x %d", deWidth, deWidth); ui.InfoBoundsTable->item(1, 1)->setText(QString(m_DEString)); } else