GNOME Bugzilla – Bug 777214
Crash on enter in search
Last modified: 2017-07-14 14:14:25 UTC
Steps to reproduce 1. open nautilus 2. type something to search for 3. delete the characters with backspace 4. press enter Expected: nothing What happens: Nautilus crashes on pressing enter with the empty search field.
Created attachment 343456 [details] [review] files-view: fix crash on enter in search Pressing enter with no selection while in search makes Nautilus crash. The problem is that Nautilus will try to access the first element of a list that is NULL. To avoid this, make sure that the list is not NULL.
Review of attachment 343456 [details] [review]: ::: src/nautilus-files-view.c @@ +1142,3 @@ NULL); + if (nautilus_files_view_supports_extract_here (view) && files != NULL) Sure, but I’m a bit dubious whether the placement of the null check is correct, since the else block will be executed in cases as described here, resulting in an unnecessary function call, etc. Though I prefer using indentation sparingly, I think the check belongs inside.
(In reply to Ernestas Kulik from comment #2) > Review of attachment 343456 [details] [review] [review]: > > ::: src/nautilus-files-view.c > @@ +1142,3 @@ > NULL); > > + if (nautilus_files_view_supports_extract_here (view) && files != NULL) > > Sure, but I’m a bit dubious whether the placement of the null check is > correct, since the else block will be executed in cases as described here, > resulting in an unnecessary function call, etc. > > Though I prefer using indentation sparingly, I think the check belongs > inside. Thanks for the review. You're right, we shouldn't have that unnecessary function call when the list is NULL
Created attachment 344038 [details] [review] files-view: fix crash on enter in search Pressing enter with no selection while in search makes Nautilus crash. The problem is that Nautilus will try to access the first element of a list that is NULL. To avoid this, make sure that the list is not NULL.
Review of attachment 344038 [details] [review]: LGTM, thanks!
Review of attachment 344038 [details] [review]: Hey, thanks Ernestas and Alex! Sorry to step on your review, but that function doesn't make sense if there is nothing to activate. either we should early return at the start of the function if that's the case or not call this function at all from the callers if this is the case. Probably the former.
(In reply to Carlos Soriano from comment #6) > Sorry to step on your review, but that function doesn't make sense if there > is nothing to activate. either we should early return at the start of the > function if that's the case or not call this function at all from the > callers if this is the case. Probably the former. Yeah, that makes more sense.
Created attachment 344139 [details] [review] files-view: fix crash on enter in search Pressing enter with no selection while in search makes Nautilus crash. The problem is that Nautilus will try to access the first element of a list that is NULL. To avoid this, make sure that the list is not NULL.
Review of attachment 344139 [details] [review]: Just push after fixing it ::: src/nautilus-files-view.c @@ +1139,3 @@ + if (files == NULL) + return; + The new code style!!! :D if () { return; }
(In reply to Carlos Soriano from comment #9) > Review of attachment 344139 [details] [review] [review]: > > Just push after fixing it > > ::: src/nautilus-files-view.c > @@ +1139,3 @@ > + if (files == NULL) > + return; > + > > The new code style!!! :D > > if () > { > return; > } Ah, that's right, sry :D
Created attachment 344146 [details] [review] files-view: fix crash on enter in search Pressing enter with no selection while in search makes Nautilus crash. The problem is that Nautilus will try to access the first element of a list that is NULL. To avoid this, make sure that the list is not NULL.
Attachment 344146 [details] pushed as 82a2d53 - files-view: fix crash on enter in search
*** Bug 781344 has been marked as a duplicate of this bug. ***
*** Bug 781381 has been marked as a duplicate of this bug. ***
*** Bug 784952 has been marked as a duplicate of this bug. ***