From b8355c656cf1206d4ab541e0aaf8bef2d4f43645 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 20 May 2017 11:11:14 -0700 Subject: [PATCH] libobs/util: Also remove CR/LF from dstr_depad Prevents newline characters from being included in things like stream keys --- libobs/util/dstr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libobs/util/dstr.c b/libobs/util/dstr.c index 73cf05222..ac56be716 100644 --- a/libobs/util/dstr.c +++ b/libobs/util/dstr.c @@ -197,6 +197,11 @@ wchar_t *wstrstri(const wchar_t *str, const wchar_t *find) return NULL; } +static inline bool is_padding(char ch) +{ + return ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'; +} + char *strdepad(char *str) { char *temp; @@ -210,7 +215,7 @@ char *strdepad(char *str) temp = str; /* remove preceding spaces/tabs */ - while (*temp == ' ' || *temp == '\t') + while (is_padding(*temp)) ++temp; len = strlen(str); @@ -219,7 +224,7 @@ char *strdepad(char *str) if (len) { temp = str + (len-1); - while (*temp == ' ' || *temp == '\t') + while (is_padding(*temp)) *(temp--) = 0; }