Avoid crash when calling warning too early
[deliverable/binutils-gdb.git] / gdb / target.c
index 2d98954b54ac9f0612e2ccdb80fe7ff51900dbde..9404025104f822a0461f9222c9aa9a338ea7dcfd 100644 (file)
@@ -584,10 +584,16 @@ target_terminal::info (const char *arg, int from_tty)
 
 /* See target.h.  */
 
-int
+bool
 target_supports_terminal_ours (void)
 {
-  return current_top_target ()->supports_terminal_ours ();
+  /* This can be called before there is any target, so we must check
+     for nullptr here.  */
+  target_ops *top = current_top_target ();
+
+  if (top == nullptr)
+    return false;
+  return top->supports_terminal_ours ();
 }
 
 static void
This page took 0.024834 seconds and 4 git commands to generate.