summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Nagy <xnagytibor@gmail.com>2020-03-05 18:23:10 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-05 19:04:14 +0100
commitc982bfee7e992775b9484f87bbfcdbe56cb66f03 (patch)
tree4bd616f4fdac04ddfb5d0992a0ef99b92be0178b
parent85eb1d26d523874e5fea1f51d629b24a1bd7918b (diff)
downloadserenity-c982bfee7e992775b9484f87bbfcdbe56cb66f03.zip
FileManager: Fix asserts on checking properties of symlinks
There were two issues with this code: - The result of the readlink() call was checked incorrectly for errors. - This code shouldn't return because otherwise it leaves the GUI buttons uninitialized below, causing RefPtr asserts to trigger when the dialog tries to access the buttons later on.
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp
index b6acacf6b6..f614c9107e 100644
--- a/Applications/FileManager/PropertiesDialog.cpp
+++ b/Applications/FileManager/PropertiesDialog.cpp
@@ -107,12 +107,11 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo
if (S_ISLNK(m_mode)) {
char link_destination[PATH_MAX];
- if (readlink(path.characters(), link_destination, sizeof(link_destination))) {
+ if (readlink(path.characters(), link_destination, sizeof(link_destination)) < 0) {
perror("readlink");
- return;
+ } else {
+ properties.append({ "Link target:", link_destination });
}
-
- properties.append({ "Link target:", link_destination });
}
properties.append({ "Size:", String::format("%zu bytes", st.st_size) });