mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
shuf: Fix division by zero when no lines are read
This commit is contained in:
parent
0588db5c30
commit
c63bdba955
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