Skip to content

Commit

Permalink
[bug] Use stack string in UUID generation
Browse files Browse the repository at this point in the history
This triggered a bug on Windows on freeing the string. Removing the
heap allocation fixed the bug, so I didn't look further.
  • Loading branch information
grandchild committed Jan 1, 2025
1 parent 433c092 commit 71acf34
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions avs/uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#endif

std::string uuid4() {
auto uuid_str = (char*)malloc(37);
char uuid_str[37];
uuid_str[36] = '\0';
#ifdef _WIN32
UUID uuid;
Expand All @@ -18,7 +18,5 @@ std::string uuid4() {
uuid_generate(uuid);
uuid_unparse_lower(uuid, uuid_str);
#endif
auto retval = std::string(uuid_str);
free(uuid_str);
return retval;
return uuid_str;
}

0 comments on commit 71acf34

Please sign in to comment.