[Lldb-commits] [lldb] r181080 - fix a couple of clang static analyzer warnings.

Jason Molenda jmolenda at apple.com
Fri May 3 17:39:52 PDT 2013


Author: jmolenda
Date: Fri May  3 19:39:52 2013
New Revision: 181080

URL: http://llvm.org/viewvc/llvm-project?rev=181080&view=rev
Log:
fix a couple of clang static analyzer warnings.
Most important was a new[] + delete mismatch in ScanFormatDescriptor()
and a couple of possible memory leaks in FileSpec::EnumerateDirectory().

Modified:
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/source/API/SBListener.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Host/common/FileSpec.cpp
    lldb/trunk/source/Target/StopInfo.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri May  3 19:39:52 2013
@@ -2980,6 +2980,7 @@ public:
     GetWatchpointSupportInfo (uint32_t &num)
     {
         Error error;
+        num = 0;
         error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported");
         return error;
     }
@@ -2988,6 +2989,8 @@ public:
     GetWatchpointSupportInfo (uint32_t &num, bool& after)
     {
         Error error;
+        num = 0;
+        after = true;
         error.SetErrorString ("Process::GetWatchpointSupportInfo() not supported");
         return error;
     }

Modified: lldb/trunk/source/API/SBListener.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBListener.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/source/API/SBListener.cpp (original)
+++ lldb/trunk/source/API/SBListener.cpp Fri May  3 19:39:52 2013
@@ -131,15 +131,13 @@ SBListener::StopListeningForEventClass (
 uint32_t
 SBListener::StartListeningForEvents (const SBBroadcaster& broadcaster, uint32_t event_mask)
 {
-    Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
-
     uint32_t acquired_event_mask = 0;
     if (m_opaque_ptr && broadcaster.IsValid())
     {
         acquired_event_mask = m_opaque_ptr->StartListeningForEvents (broadcaster.get(), event_mask);
     }
     
-    log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
+    Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
     if (log)
     {
         StreamString sstr_requested;

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Fri May  3 19:39:52 2013
@@ -1179,7 +1179,7 @@ ScanFormatDescriptor (const char* var_na
                 log->Printf("ScanFormatDescriptor] will display value for this VO");
             *val_obj_display = ValueObject::eValueObjectRepresentationStyleValue;
         }
-        delete format_name;
+        delete[] format_name;
     }
     if (log)
         log->Printf("ScanFormatDescriptor] final format description outcome: custom_format = %d, val_obj_display = %d",

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Fri May  3 19:39:52 2013
@@ -985,9 +985,13 @@ FileSpec::EnumerateDirectory
                         case eEnumerateDirectoryResultExit:  // Exit from the current directory at the current level.
                             // Exit from this directory level and tell parent to 
                             // keep enumerating.
+                            if (buf)
+                                free (buf);
                             return eEnumerateDirectoryResultNext;
 
                         case eEnumerateDirectoryResultQuit:  // Stop directory enumerations at any level
+                            if (buf)
+                                free (buf);
                             return eEnumerateDirectoryResultQuit;
                         }
                     }

Modified: lldb/trunk/source/Target/StopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/source/Target/StopInfo.cpp (original)
+++ lldb/trunk/source/Target/StopInfo.cpp Fri May  3 19:39:52 2013
@@ -661,7 +661,8 @@ protected:
                     // re-enable the watchpoint
                     if (process)
                     {
-                        uint32_t num; bool wp_triggers_after;
+                        uint32_t num;
+                        bool wp_triggers_after;
                         if (process->GetWatchpointSupportInfo(num, wp_triggers_after).Success())
                         {
                             if (!wp_triggers_after)

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Fri May  3 19:39:52 2013
@@ -1023,7 +1023,7 @@ MachTask::EnumerateMallocFrames (MachMal
     
     __mach_stack_logging_frames_for_uniqued_stack(m_task, event_id, &function_addresses_buffer[0], buffer_size, count);
     *count -= 1;
-    if (function_addresses_buffer[*count-1] < vm_page_size)
+    if (function_addresses_buffer[*count-1] < PageSize())
         *count -= 1;
     return (*count > 0);
 }

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp?rev=181080&r1=181079&r2=181080&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp Fri May  3 19:39:52 2013
@@ -206,9 +206,7 @@ MachVMMemory::GetStolenPages(task_t task
 			if(stolen >= mb128)
             {
                 stolen = (stolen & ~((128 * 1024 * 1024ULL) - 1)); // rounding down
-                vm_size_t pagesize = vm_page_size;
-                pagesize = PageSize (task);
-                stolenPages = stolen/pagesize;
+                stolenPages = stolen / PageSize (task);
 			}
 		}
 	}





More information about the lldb-commits mailing list