瀏覽代碼

Fixes a possible size mismatch for isspace() (#7311)

* Fixes #5928.
* Passing a char type argument to isspace() could result in unpredictable results.
Thanks to @hyunji-Hong and @Lemongrass3110!
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Aleos 2 年之前
父節點
當前提交
8138281d90
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      src/common/strlib.cpp

+ 2 - 2
src/common/strlib.cpp

@@ -155,7 +155,7 @@ char* trim(char* str)
 // value must NOT be deallocated using free() etc.
 char *trim2(char *str,char flag) {
 	if(flag&1) { // Trim leading space
-		while(isspace(*str)) str++;
+		while(ISSPACE(*str)) str++;
 		if(*str == 0)  // All spaces?
 			return str;
 	}
@@ -163,7 +163,7 @@ char *trim2(char *str,char flag) {
 		char *end;
 
 		end = str + strlen(str) - 1;
-		while(end > str && isspace(*end)) end--;
+		while(end > str && ISSPACE(*end)) end--;
 		*(end+1) = 0; // Write new null terminator
 	}