Add Null check to lib_name before getting string length.
authorLakshmi Priya Sekar <lasekar@microsoft.com>
Wed, 7 Oct 2015 18:04:19 +0000 (11:04 -0700)
committerLakshmi Priya Sekar <lasekar@microsoft.com>
Thu, 8 Oct 2015 18:07:39 +0000 (11:07 -0700)
src/pal/src/debug/debug.cpp
src/pal/src/include/pal/stackstring.hpp

index e36a46b..fc86290 100644 (file)
@@ -345,7 +345,13 @@ DebugBreakCommand()
     if (command_string) {
         char pid_buf[sizeof (PID_TEXT) + 32];
         PathCharString exe_bufString;
-        SIZE_T dwexe_buf = strlen(EXE_TEXT) + PAL_wcslen(exe_module.lib_name) + 1;
+        int libNameLength = 10;
+        if (exe_module.lib_name != NULL)
+        {
+            libNameLength = PAL_wcslen(exe_module.lib_name);
+        }
+        
+        SIZE_T dwexe_buf = strlen(EXE_TEXT) + libNameLength + 1;
         CHAR * exe_buf = exe_bufString.OpenStringBuffer(dwexe_buf);
 
         if (snprintf (pid_buf, sizeof (pid_buf), PID_TEXT "%d", getpid()) <= 0) {
index aa8bd3e..392c831 100644 (file)
@@ -16,7 +16,7 @@ private:
 
     void NullTerminate()
     {
-        m_buffer[m_count] = W('\0');
+        m_buffer[m_count] = 0;
     }
 
     void DeleteBuffer()
@@ -105,10 +105,15 @@ public:
         return Set(s.m_buffer, s.m_count);
     }
 
-    SIZE_T Getcount() const
+    SIZE_T GetCount() const
     {
         return m_count;
     }
+    
+    SIZE_T GetSizeOf() const
+    {
+        return (m_count+1) * sizeof(T);
+    }
 
     CONST T * GetString() const
     {