Skip to content

Commit 3626c40

Browse files
Fix code scanning alert no. 3: Use of potentially dangerous function
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent a7a99f3 commit 3626c40

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utils/utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ std::string percentEncode(std::string str, std::string reserved) {
157157
}
158158

159159
std::string getTime(std::string format, const time_t* timer) {
160-
struct tm* timeinfo;
160+
struct tm timeinfo;
161161
size_t size = 64;
162162

163163
time_t rawtime;
@@ -168,8 +168,8 @@ std::string getTime(std::string format, const time_t* timer) {
168168
if (endsWith(format, " GMT") == false) format += " GMT";
169169
while (true) {
170170
std::string buffer(size, '\0');
171-
timeinfo = std::gmtime(timer);
172-
size_t ret = std::strftime(&buffer[0], size, format.c_str(), timeinfo);
171+
std::gmtime_r(timer, &timeinfo);
172+
size_t ret = std::strftime(&buffer[0], size, format.c_str(), &timeinfo);
173173
if (ret != 0) {
174174
buffer.resize(ret);
175175
return buffer;

0 commit comments

Comments
 (0)