From 168244e422b713862733b588cca1f3a49954427d Mon Sep 17 00:00:00 2001 From: Evan Pezent Date: Sun, 30 Jan 2022 09:54:49 -0800 Subject: [PATCH] replace sprintf with snprintf --- implot_items.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implot_items.cpp b/implot_items.cpp index 8f67b37..6177a4a 100644 --- a/implot_items.cpp +++ b/implot_items.cpp @@ -1906,7 +1906,7 @@ void PlotPieChart(const char* const label_ids[], const T* values, int count, dou double percent = normalize ? (double)values[i] / sum : (double)values[i]; a1 = a0 + 2 * IM_PI * percent; if (item->Show) { - sprintf(buffer, fmt, (double)values[i]); + snprintf(buffer, 32, fmt, (double)values[i]); ImVec2 size = ImGui::CalcTextSize(buffer); double angle = a0 + (a1 - a0) * 0.5; ImVec2 pos = PlotToPixels(center.x + 0.5 * radius * cos(angle), center.y + 0.5 * radius * sin(angle),IMPLOT_AUTO,IMPLOT_AUTO); @@ -2060,7 +2060,7 @@ void RenderHeatmap(Transformer transformer, ImDrawList& DrawList, const T* value p.y = yref + ydir * (0.5*h + r*h); ImVec2 px = transformer(p); char buff[32]; - sprintf(buff, fmt, values[i]); + sprintf(buff, 32, fmt, values[i]); ImVec2 size = ImGui::CalcTextSize(buff); double t = ImClamp(ImRemap01((double)values[i], scale_min, scale_max),0.0,1.0); ImVec4 color = SampleColormap((float)t);