Skip to content

Commit

Permalink
Reduce chance of ogg serial number collision on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmf01 committed Sep 12, 2024
1 parent 87283b7 commit 14b0a00
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/flac/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#ifdef _WIN32
#include <windows.h>
#endif
#endif

#if !defined _MSC_VER && !defined __MINGW32__
Expand Down Expand Up @@ -338,6 +342,10 @@ static int main_to_fuzz(int argc, char *argv[])
srand((uint32_t)(tv.tv_sec) * 1e6 + (uint32_t)tv.tv_usec);
}
}
#else
#ifdef _WIN32
/* For Windows, use time and GetTickCount */
srand(((uint32_t)time(0) << 8) + ((uint32_t)GetTickCount() & 0xff));
#else
/* time(0) does not have sufficient resolution when flac is invoked more than
* once in quick succession (for example in the test suite). As far as I know,
Expand All @@ -349,6 +357,7 @@ static int main_to_fuzz(int argc, char *argv[])
*/
srand(((uint32_t)time(0) << 8) + (uint32_t)clock());
#endif
#endif

#ifdef _WIN32
{
Expand Down

0 comments on commit 14b0a00

Please sign in to comment.