mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-27 17:06:29 +00:00
Prevent trim() from segfaulting on an empty string
This commit is contained in:
4
config.c
4
config.c
@@ -185,6 +185,10 @@ trim(char *s)
|
|||||||
char *s1 = s,
|
char *s1 = s,
|
||||||
*s2 = &s[strlen(s) - 1];
|
*s2 = &s[strlen(s) - 1];
|
||||||
|
|
||||||
|
/* If string is empty, no action needed */
|
||||||
|
if(s2 < s1)
|
||||||
|
return s;
|
||||||
|
|
||||||
/* Trim and delimit right side */
|
/* Trim and delimit right side */
|
||||||
while ((isspace(*s2)) && (s2 >= s1))
|
while ((isspace(*s2)) && (s2 >= s1))
|
||||||
--s2;
|
--s2;
|
||||||
|
|||||||
Reference in New Issue
Block a user