summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 7e3bc372..cf783893 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -192,7 +192,12 @@ char *_alpm_strtrim(char *str)
pch++;
}
if(pch != str) {
- memmove(str, pch, (strlen(pch) + 1));
+ size_t len = strlen(pch);
+ if(len) {
+ memmove(str, pch, len + 1);
+ } else {
+ *str = '\0';
+ }
}
/* check if there wasn't anything but whitespace in the string. */