# HG changeset patch # User jwe # Date 838277463 0 # Node ID 0f441b4fefdb05ec8766560f081e9c954c1be8b4 # Parent 968a33af8b3d3310121dd957dd15b7cb8159a94e [project @ 1996-07-25 06:51:03 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Thu Jul 25 01:42:38 1996 John W. Eaton + + * load-save.cc (read_mat_binary_data): Expect to read terminating + NUL character in the variable name. + (save_mat_binary_data): Likewise, save it here. + Wed Jul 24 05:08:07 1996 John W. Eaton * lsode.cc (Flsode): Don't set the return value if an error diff --git a/src/load-save.cc b/src/load-save.cc --- a/src/load-save.cc +++ b/src/load-save.cc @@ -1147,8 +1147,10 @@ return 0; } - name = new char [len+1]; - name[len] = '\0'; + // LEN includes the terminating character, and the file is also + // supposed to include it. + + name = new char [len]; if (! is.read (name, len)) goto data_read_error; @@ -1784,10 +1786,13 @@ FOUR_BYTE_INT imag = tc.is_complex_type () ? 1 : 0; os.write (&imag, 4); - FOUR_BYTE_INT name_len = name.length (); + // LEN includes the terminating character, and the file is also + // supposed to include it. + + FOUR_BYTE_INT name_len = name.length () + 1; os.write (&name_len, 4); - os << name; + os << name << '\0'; if (tc.is_real_scalar ()) {