Skip to content

Commit

Permalink
replace localtime with _s/_r variant
Browse files Browse the repository at this point in the history
cppcheck warns on localtime which is not necessarily threadsafe.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Feb 11, 2023
1 parent 3c36b30 commit ebc2d6e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,12 @@ void CrwMap::decode0x180e(const CiffComponent& ciffComponent, const CrwMapping*
ULongValue v;
v.read(ciffComponent.pData(), 8, byteOrder);
time_t t = v.value_.at(0);
auto tm = std::localtime(&t);
struct tm r;
#ifdef _WIN32
auto tm = localtime_s(&r, &t) ? NULL : &r;
#else
auto tm = localtime_r(&t, &r);
#endif
if (tm) {
const size_t m = 20;
char s[m];
Expand Down

0 comments on commit ebc2d6e

Please sign in to comment.