mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
clipboard: Check for empty string when deserializing
It's possible that nautilus_clipbaord_from_string() receives an empty string. When an empty string is received nautilus crashes because g_str_equal() cannot handle the null value returned from g_strsplit(). We could simply change g_str_equal() to g_strcmp0() but that opens up the possibility for the for loop to give unexpected results (it only checks for NULL starting at index=1). Check if the results from g_strsplit()[0] == NULL and return early.
This commit is contained in:
parent
0aa1b66ffa
commit
f5465fdf7e
|
@ -79,6 +79,11 @@ nautilus_clipboard_from_string (char *string)
|
|||
{
|
||||
lines = g_strsplit (string, "\n", 0);
|
||||
|
||||
if (lines[0] == NULL)
|
||||
{
|
||||
return clip;
|
||||
}
|
||||
|
||||
/* Line 0 is "cut" or "copy", so uris start at line 1. */
|
||||
clip->cut = g_str_equal (lines[0], "cut");
|
||||
for (int i = 1; lines[i] != NULL; i++)
|
||||
|
|
Loading…
Reference in a new issue