changeset 11569:7e9a111cae20

allocate sufficient space for strmode
author John W. Eaton <jwe@octave.org>
date Wed, 19 Jan 2011 15:12:59 -0500
parents de5fba8337c5
children 57632dea2446
files liboctave/ChangeLog liboctave/file-stat.cc
diffstat 2 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-19  John W. Eaton  <jwe@octave.org>
+
+	* file-stat.cc (mode_as_string): Declare buffer as an array of
+	12 characters, not 11.  Don't set buf[10] to '\0'; strmode
+	NUL-terminates the array.
+
 2011-01-14  David Grundberg  <individ@acc.umu.se>
 
 	* SparseQR.cc (SparseQR_rep::SparseQR_rep) [HAVE_CXSPARSE]:
--- a/liboctave/file-stat.cc
+++ b/liboctave/file-stat.cc
@@ -155,12 +155,10 @@
 std::string
 base_file_stat::mode_as_string (void) const
 {
-  char buf[11];
+  char buf[12];
 
   strmode (fs_mode, buf);
 
-  buf[10] = '\0';
-
   return std::string (buf);
 }