mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
Userland: ls division by zero.
When the terminal app window became smaller than the longest filename, a division by zero occured while calculating the offset.
This commit is contained in:
parent
c106ec4719
commit
d4b7b92492
Notes:
sideshowbarker
2024-07-19 12:35:11 +09:00
Author: https://github.com/marprok Commit: https://github.com/SerenityOS/serenity/commit/d4b7b924925 Pull-request: https://github.com/SerenityOS/serenity/pull/471
1 changed files with 3 additions and 1 deletions
|
@ -272,7 +272,9 @@ int do_file_system_object_short(const char* path)
|
|||
|
||||
if (!print_filesystem_object_short(pathbuf, name.characters(), &nprinted))
|
||||
return 2;
|
||||
int offset = columns % longest_name / (columns / longest_name);
|
||||
int offset = 0;
|
||||
if (columns > longest_name)
|
||||
offset = columns % longest_name / (columns / longest_name);
|
||||
/* The offset must be at least 2 because:
|
||||
* - With each file an aditional char is printed e.g. '@','*'.
|
||||
* - Each filename must be separated by a space.
|
||||
|
|
Loading…
Reference in a new issue