Skip to content

Commit

Permalink
Added clearer range checks for string class to help compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Oct 21, 2014
1 parent 963d7c5 commit 869ff34
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qtools/qcstring.h
Expand Up @@ -431,7 +431,7 @@ class QCString
StringRep(int size)
{
u.s.isShort = size<=SHORT_STR_CAPACITY;
if (u.s.isShort) // init short string
if (size<=SHORT_STR_CAPACITY) // init short string
{
if (size>0)
{
Expand All @@ -453,8 +453,8 @@ class QCString
if (str)
{
int len = strlen(str);
u.s.isShort = len<=SHORT_STR_MAX_LEN;
if (u.s.isShort)
u.s.isShort = len<SHORT_STR_CAPACITY;
if (len<SHORT_STR_CAPACITY)
{
u.s.len = len;
memcpy(u.s.str,str,len+1);
Expand Down Expand Up @@ -527,7 +527,7 @@ class QCString
{
int len = strlen(str);
u.s.isShort = len<=SHORT_STR_MAX_LEN;
if (u.s.isShort)
if (len<SHORT_STR_CAPACITY)
{
u.s.len = len;
memcpy(u.s.str,str,len+1);
Expand Down

0 comments on commit 869ff34

Please sign in to comment.