[gnome-builder] terminal: check for valid runtime before using



commit a74891a8cdb9ed4559417e508e21dae9da1b97c9
Author: Christian Hergert <chergert redhat com>
Date:   Mon Feb 21 11:09:05 2022 -0800

    terminal: check for valid runtime before using
    
    Fixes #1636

 src/libide/terminal/ide-terminal-launcher.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/terminal/ide-terminal-launcher.c b/src/libide/terminal/ide-terminal-launcher.c
index 3b4f59baf..7c8e76c26 100644
--- a/src/libide/terminal/ide-terminal-launcher.c
+++ b/src/libide/terminal/ide-terminal-launcher.c
@@ -328,9 +328,18 @@ spawn_runtime_launcher (IdeTerminalLauncher *self,
 
   g_assert (IDE_IS_TERMINAL_LAUNCHER (self));
   g_assert (IDE_IS_TASK (task));
-  g_assert (IDE_IS_RUNTIME (runtime));
+  g_assert (!runtime || IDE_IS_RUNTIME (runtime));
   g_assert (pty_fd >= 0);
 
+  if (runtime == NULL)
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_FAILED,
+                                 _("Requested runtime is not installed"));
+      return;
+    }
+
   if (!(shell = ide_terminal_launcher_get_shell (self)))
     shell = ide_get_user_shell ();
 
@@ -419,9 +428,18 @@ spawn_runner_launcher (IdeTerminalLauncher *self,
 
   g_assert (IDE_IS_TERMINAL_LAUNCHER (self));
   g_assert (IDE_IS_TASK (task));
-  g_assert (IDE_IS_RUNTIME (runtime));
+  g_assert (!runtime || IDE_IS_RUNTIME (runtime));
   g_assert (pty_fd >= 0);
 
+  if (runtime == NULL)
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_FAILED,
+                                 _("Requested runtime is not installed"));
+      return;
+    }
+
   if (!(shell = ide_terminal_launcher_get_shell (self)))
     shell = ide_get_user_shell ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]