fix breakage when ast_copy_string is used to copy substrings (bug #4146, but a differ...
[asterisk/asterisk.git] / utils.c
diff --git a/utils.c b/utils.c
index b73e4fc..e83d86f 100755 (executable)
--- a/utils.c
+++ b/utils.c
@@ -420,8 +420,10 @@ int ast_wait_for_input(int fd, int ms)
 
 void ast_copy_string(char *dst, const char *src, size_t size)
 {
-       while (*src && size--)
+       while (*src && size) {
                *dst++ = *src++;
+               size--;
+       }
        if (__builtin_expect(!size, 0))
                dst--;
        *dst = '\0';