changeset 29019:be883573bbcc

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.
author Rik <rik@octave.org>
date Tue, 03 Nov 2020 10:35:32 -0800
parents c44969d941f9
children 1db3841f042f
files libinterp/corefcn/load-save.cc
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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,