[lldb] Fix use-of-uninitialized-value in Driver
authorJorge Gorbe Moya <jgorbe@google.com>
Wed, 22 May 2019 23:37:48 +0000 (23:37 +0000)
committerJorge Gorbe Moya <jgorbe@google.com>
Wed, 22 May 2019 23:37:48 +0000 (23:37 +0000)
The driver passes by reference an uninitialized num_errors variable to
RunCommandInterpreter. This should be fine, as it's supposed to be
an output argument, but the reproducer instrumentation reads it in order
to record the value of all the arguments to the function.

This change fixes it by initializing num_errors to 0 before calling
RunCommandInterpreter.

llvm-svn: 361444

lldb/tools/driver/Driver.cpp

index 34711d52aa274ec5942d767cc2dc8f6d9f651bde..53fa1b2e89adfc01c3f85c9a4bf477fd940061ea 100644 (file)
@@ -610,7 +610,7 @@ int Driver::MainLoop() {
       // that run the target won't run in a sensible way.
       bool old_async = m_debugger.GetAsync();
       m_debugger.SetAsync(false);
-      int num_errors;
+      int num_errors = 0;
 
       SBCommandInterpreterRunOptions options;
       options.SetStopOnError(true);