Skip to content

Commit dc41b3c

Browse files
this time
1 parent d4cbf9d commit dc41b3c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code/logic/fossil/media/text.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ namespace fossil {
102102
*/
103103
static std::string trim(const std::string& str) {
104104
std::string s = str;
105-
char *buf = new char[s.size() + 1];
106-
std::strcpy(buf, s.c_str());
105+
char *buf = new char[s.size() + 2](); // +2 for safety and zero-initialize
106+
std::strncpy(buf, s.c_str(), s.size());
107+
buf[s.size()] = '\0'; // Ensure null-termination
107108
fossil_media_text_trim(buf);
108109
std::string result(buf);
109110
delete[] buf;

0 commit comments

Comments
 (0)