From 0ce4ea4abdb3e76d3e1cee5365a2aca7344b25dd Mon Sep 17 00:00:00 2001 From: gambinoxxx Date: Mon, 27 Oct 2025 22:13:43 -0700 Subject: [PATCH] fix: Correct critical bugs and improve code quality This commit addresses several critical bugs and improves the overall code quality in various game implementations within the repository. - C++ Hangman Game (Hangman.cpp): - Resolved a critical buffer overflow that caused crashes by correctly sizing std::string variables before use. - Replaced unsafe C-style string loops with modern C++ std::string::length() checks for better safety and clarity. - Substituted the non-portable system("clear") with a cross-platform alternative for screen clearing. - JavaScript Dodgeball Game (loginregister.html): - Fixed a bug where login and registration forms used duplicate HTML id's, causing incorrect element selection in JavaScript. - Added a security warning regarding the insecure practice of storing passwords in localStorage. - JavaScript ConnectFour Game (registration.js): - Completed the showRankingsTable function, which was missing the logic to generate and display the rankings table from localStorage data. These changes ensure the applications run more reliably and adhere to better coding and security practices. --- Languages/C++/Hangman.cpp | 26 +++++++++---------- .../ConnectFour Game/registration.js | 6 +++-- .../Javascript/Dodgeball/loginregister.html | 12 ++++----- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/Languages/C++/Hangman.cpp b/Languages/C++/Hangman.cpp index 6cb4df6d..dc3643c2 100644 --- a/Languages/C++/Hangman.cpp +++ b/Languages/C++/Hangman.cpp @@ -25,19 +25,19 @@ int main() cout<<"Player's 1 turn.Player 1 needs to enter word-"; getline(cin,word); //Input String cout<>letter; letter=toupper(letter); // Convert into Upper case cout<>guess; - cout<" + usrObj.topscore + ""; //Add a table row to the HTML string. } } //Finish off the table htmlStr += ""; - + //Add the table to the page. + rankingDiv.innerHTML = htmlStr; } \ No newline at end of file diff --git a/Languages/Javascript/Dodgeball/loginregister.html b/Languages/Javascript/Dodgeball/loginregister.html index 571aa026..dfd5f5d9 100644 --- a/Languages/Javascript/Dodgeball/loginregister.html +++ b/Languages/Javascript/Dodgeball/loginregister.html @@ -63,10 +63,10 @@

Login