1
Fork 0
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:
SeekingBlues 2021-10-13 19:58:48 -04:00 committed by Brian Gianforcaro
parent 0588db5c30
commit c63bdba955

View file

@ -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) {