]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: auth_stream_reply_remove() left extra TABs to stream.
authorTimo Sirainen <tss@iki.fi>
Sat, 25 Feb 2012 02:38:01 +0000 (04:38 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 25 Feb 2012 02:38:01 +0000 (04:38 +0200)
Normally this wouldn't really affect anything, except log some extra debug
messages.

src/auth/auth-stream.c

index 0c0d7d3c62146d09a5fcf59328e4e06c6df2681d..d62c36984d9bdf19acd8ab2e10477dd9515a556b 100644 (file)
@@ -76,15 +76,16 @@ void auth_stream_reply_remove(struct auth_stream_reply *reply, const char *key)
        if (!auth_stream_reply_find_area(reply, key, &idx, &len))
                return;
 
-       if (str_len(reply->str) < idx + len) {
-               /* remove also trailing tab */
-               len++;
-       } else if (str_len(reply->str) == idx + len && idx > 0) {
-               /* removing last item, remove preceding tab */
+       if (idx == 0 && str_len(reply->str) == len) {
+               /* removing the only item */
+       } else if (str_len(reply->str) == idx + len) {
+               /* removing the last item -> remove the preceding tab */
                len++;
                idx--;
+       } else {
+               /* remove the trailing tab */
+               len++;
        }
-
        str_delete(reply->str, idx, len);
 }