浏览代码

libobs: Don't strip whitespace from config values

A plugin that saves whitespace-only data would crash OBS on startup as
the whitespace stripping would send the string length negative. While
that bug is fixed in this commit, there is also no good reason that OBS
is stripping whitespace to begin with. All data going into the configs
should be well formed and some plugins legitimately wish to save
whitespace as a config option (eg for search / replace characters).
Richard Stanway 5 年之前
父节点
当前提交
862f16285f
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      libobs/util/config-file.c

+ 2 - 2
libobs/util/config-file.c

@@ -95,7 +95,7 @@ config_t *config_create(const char *file)
 static inline void remove_ref_whitespace(struct strref *ref)
 static inline void remove_ref_whitespace(struct strref *ref)
 {
 {
 	if (ref->array) {
 	if (ref->array) {
-		while (is_whitespace(*ref->array)) {
+		while (ref->len && is_whitespace(*ref->array)) {
 			ref->array++;
 			ref->array++;
 			ref->len--;
 			ref->len--;
 		}
 		}
@@ -130,7 +130,7 @@ static bool config_parse_string(struct lexer *lex, struct strref *ref, char end)
 		strref_add(ref, &token.text);
 		strref_add(ref, &token.text);
 	}
 	}
 
 
-	remove_ref_whitespace(ref);
+	//remove_ref_whitespace(ref);
 	return success;
 	return success;
 }
 }