mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +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);
|
free(buffer);
|
||||||
|
|
||||||
|
if (lines.is_empty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
// Fisher-Yates shuffle
|
// Fisher-Yates shuffle
|
||||||
String tmp;
|
String tmp;
|
||||||
for (size_t i = lines.size() - 1; i >= 1; --i) {
|
for (size_t i = lines.size() - 1; i >= 1; --i) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue