mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-11-16 00:13:00 +00:00
Potential buffer overflow, use snprintf instead
This commit is contained in:
parent
159305bbc7
commit
5057a47b05
@ -1205,17 +1205,17 @@ void render_benchmark(swapchain_stats& data, struct overlay_params& params, ImVe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::Begin("Benchmark", &open, ImGuiWindowFlags_NoDecoration);
|
ImGui::Begin("Benchmark", &open, ImGuiWindowFlags_NoDecoration);
|
||||||
string finished = "Logging Finished";
|
static const char* finished = "Logging Finished";
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(finished.c_str()).x / 2));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(finished).x / 2));
|
||||||
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), finished.c_str());
|
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), finished);
|
||||||
ImGui::Dummy(ImVec2(0.0f, 8.0f));
|
ImGui::Dummy(ImVec2(0.0f, 8.0f));
|
||||||
char duration[20];
|
char duration[20];
|
||||||
sprintf(duration, "Duration: %.1fs", float(log_end - log_start) / 1000000);
|
snprintf(duration, sizeof(duration), "Duration: %.1fs", float(log_end - log_start) / 1000000);
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(duration).x / 2));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(duration).x / 2));
|
||||||
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), duration);
|
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), duration);
|
||||||
for (auto& data_ : benchmark_data){
|
for (auto& data_ : benchmark_data){
|
||||||
char buffer[20];
|
char buffer[20];
|
||||||
sprintf(buffer, "%s %.1f", data_.first.c_str(), data_.second);
|
snprintf(buffer, sizeof(buffer), "%s %.1f", data_.first.c_str(), data_.second);
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(buffer).x / 2));
|
ImGui::SetCursorPosX((ImGui::GetWindowSize().x / 2 )- (ImGui::CalcTextSize(buffer).x / 2));
|
||||||
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), "%s %.1f", data_.first.c_str(), data_.second);
|
ImGui::TextColored(ImVec4(1.0, 1.0, 1.0, alpha / params.background_alpha), "%s %.1f", data_.first.c_str(), data_.second);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user