We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4cbf9d commit dc41b3cCopy full SHA for dc41b3c
code/logic/fossil/media/text.h
@@ -102,8 +102,9 @@ namespace fossil {
102
*/
103
static std::string trim(const std::string& str) {
104
std::string s = str;
105
- char *buf = new char[s.size() + 1];
106
- std::strcpy(buf, s.c_str());
+ char *buf = new char[s.size() + 2](); // +2 for safety and zero-initialize
+ std::strncpy(buf, s.c_str(), s.size());
107
+ buf[s.size()] = '\0'; // Ensure null-termination
108
fossil_media_text_trim(buf);
109
std::string result(buf);
110
delete[] buf;
0 commit comments