# HG changeset patch # User Rik # Date 1604428532 28800 # Node ID be883573bbccee9a4c3eda4570438f2c143a6af7 # Parent c44969d941f982f5ecf298470a613ddef7327605 Emit an error if save is called with -append, -zip, and a binary format (bug #59225) * load-save.cc (load_save_system::parse_save_options): Detect combination of -append, -zip, and a binary format and emit an error. * load-save.cc (Fsave): Add BIST test for bug #59225. diff -r c44969d941f9 -r be883573bbcc libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Mon Nov 02 13:52:57 2020 -0800 +++ b/libinterp/corefcn/load-save.cc Tue Nov 03 10:35:32 2020 -0800 @@ -645,6 +645,10 @@ warning (R"(save: "-tabs" option only has an effect with "-ascii")"); } + if (append && use_zlib + && (fmt.type () != TEXT && fmt.type () != MAT_ASCII)) + error ("save: -append and -zip options can only be used together with a text format (-text or -ascii)"); + return retval; } @@ -1850,6 +1854,12 @@ %! assert (B, B2); %! assert (C, C2); %! assert (D, D2); + +## Test input validation +%!error <-append and -zip options .* with a text format> +%! fname = tempname (); +%! x = 1; +%! save ("-append", "-zip", "-binary", fname, "x"); */ DEFMETHOD (crash_dumps_octave_core, interp, args, nargout,