Protect against overflows in RichString_setAttrn

This commit is contained in:
Hisham Muhammad
2018-02-26 11:05:12 -03:00
parent 655c7293d2
commit 858af2505f
2 changed files with 10 additions and 0 deletions

View File

@ -59,6 +59,10 @@ typedef struct RichString_ {
} RichString;
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
#define charBytes(n) (sizeof(CharType) * (n))
#define RichString_setLen(this, len) do{ if(len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) { RichString_setChar(this,len,0); this->chlen=len; } else RichString_extendLen(this,len); }while(0)