# HG changeset patch # User Rob Landley # Date 1414455631 18000 # Node ID 1d996b0a11c0a18e25936262a91a41d3a4f2fee3 # Parent b50de98c97086f04aff74cd79a720245b7c8f81d Fix use after free error spotted by ?ukasz Szpakowski. diff -r b50de98c9708 -r 1d996b0a11c0 toys/posix/tail.c --- a/toys/posix/tail.c Mon Oct 27 18:08:59 2014 -0500 +++ b/toys/posix/tail.c Mon Oct 27 19:20:31 2014 -0500 @@ -176,9 +176,13 @@ linepop = try[count] == '\n'; if (lines > 0) { + char c; + do { + c = *list->data; if (!--(list->len)) free(dlist_pop(&list)); - } while (*(list->data++) != '\n'); + else list->data++; + } while (c != '\n'); lines--; } }