From: Igor Gnatenko Date: Sun, 13 Dec 2015 14:02:05 +0000 (+0100) Subject: scols/table_print: restore old stream after printing to str X-Git-Tag: v2.28-rc1~220^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e8461a53a11b2ed4d4e14a9e912bfad02cb7287;p=thirdparty%2Futil-linux.git scols/table_print: restore old stream after printing to str Reference: https://github.com/karelzak/util-linux/issues/240 Signed-off-by: Igor Gnatenko --- diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c index caae98c142..eca61bc04b 100644 --- a/libsmartcols/src/table_print.c +++ b/libsmartcols/src/table_print.c @@ -1062,7 +1062,7 @@ done: int scols_print_table_to_string(struct libscols_table *tb, char **data) { #ifdef HAVE_OPEN_MEMSTREAM - FILE *stream; + FILE *stream, *old_stream; size_t sz; int rc; @@ -1076,9 +1076,11 @@ int scols_print_table_to_string(struct libscols_table *tb, char **data) if (!stream) return -ENOMEM; + old_stream = scols_table_get_stream(tb); scols_table_set_stream(tb, stream); rc = scols_print_table(tb); fclose(stream); + scols_table_set_stream(tb, old_stream); return rc; #else