summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/util.c7
-rw-r--r--src/util/pactree.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 2de4bd44..cb62ec66 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -342,7 +342,12 @@ char *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. */
diff --git a/src/util/pactree.c b/src/util/pactree.c
index 5a27cc77..b8832912 100644
--- a/src/util/pactree.c
+++ b/src/util/pactree.c
@@ -103,7 +103,12 @@ static char *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. */