mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
shuf: Fix division by zero when no lines are read
This commit is contained in:
parent
0588db5c30
commit
c63bdba955
Notes:
sideshowbarker
2024-07-18 02:14:01 +09:00
Author: https://github.com/SeekingBlues
Commit: c63bdba955
Pull-request: https://github.com/SerenityOS/serenity/pull/10465
Reviewed-by: https://github.com/BenWiederhake
1 changed files with 3 additions and 0 deletions
|
@ -36,6 +36,9 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
|
|||
}
|
||||
free(buffer);
|
||||
|
||||
if (lines.is_empty())
|
||||
return 0;
|
||||
|
||||
// Fisher-Yates shuffle
|
||||
String tmp;
|
||||
for (size_t i = lines.size() - 1; i >= 1; --i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue