xargs: fix my brain fart (resulted in memory leak)
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Apr 2007 21:41:16 +0000 (21:41 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 10 Apr 2007 21:41:16 +0000 (21:41 -0000)
findutils/xargs.c

index 2b3a5081c6ad8d5076d18daa68473894cb7b62dd..695091a048753957c9fd96d0be03a450ca5e4ee3 100644 (file)
@@ -113,10 +113,10 @@ static xlist_t *process_stdin(xlist_t *list_arg,
        xlist_t *cur;
        xlist_t *prev;
 
-       cur = list_arg;
+       prev = cur = list_arg;
        while (1) {
-               prev = cur;
                if (!cur) break;
+               prev = cur;
                line_l += cur->length;
                cur = cur->link;
        }
@@ -142,7 +142,6 @@ static xlist_t *process_stdin(xlist_t *list_arg,
                                goto set;
                        }
                } else { /* if(state == NORM) */
-
                        if (ISSPACE(c)) {
                                if (s) {
 unexpected_eof:
@@ -214,10 +213,10 @@ static xlist_t *process_stdin(xlist_t *list_arg,
        xlist_t *cur;
        xlist_t *prev;
 
-       cur = list_arg;
+       prev = cur = list_arg;
        while (1) {
-               prev = cur;
                if (!cur) break;
+               prev = cur;
                line_l += cur->length;
                cur = cur->link;
        }
@@ -304,10 +303,10 @@ static xlist_t *process0_stdin(xlist_t *list_arg,
        xlist_t *cur;
        xlist_t *prev;
 
-       cur = list_arg;
+       prev = cur = list_arg;
        while (1) {
-               prev = cur;
                if (!cur) break;
+               prev = cur;
                line_l += cur->length;
                cur = cur->link;
        }