Selaa lähdekoodia

Merge pull request #496 from JeffProgrammer/getWords_buffer_fix

Fix buffer overflow issue in StringUnit::getWords
Brian Roberts 4 vuotta sitten
vanhempi
commit
802598766a
1 muutettua tiedostoa jossa 3 lisäystä ja 3 poistoa
  1. 3 3
      Engine/source/core/strings/stringUnit.cpp

+ 3 - 3
Engine/source/core/strings/stringUnit.cpp

@@ -42,7 +42,7 @@ namespace StringUnit
          
          
       buffer[0] = 0;
       buffer[0] = 0;
       
       
-      U32 sz;
+      dsize_t sz;
       while(index--)
       while(index--)
       {
       {
          if(!*string)
          if(!*string)
@@ -71,7 +71,7 @@ namespace StringUnit
       if( startIndex > endIndex )
       if( startIndex > endIndex )
          return "";
          return "";
 
 
-      S32 sz;
+      dsize_t sz;
       S32 index = startIndex;
       S32 index = startIndex;
       while(index--)
       while(index--)
       {
       {
@@ -89,7 +89,7 @@ namespace StringUnit
          sz = dStrcspn(string, set);
          sz = dStrcspn(string, set);
          string += sz;
          string += sz;
 
 
-         if( i < endIndex )
+         if( i < endIndex && *string )
             string ++;
             string ++;
       }
       }