changeset 26506:9cf999911dfe stable

lo-sysdep.cc: Fix static analyzer detected issues (bug #55347). * lo-sysdep.cc (putenv_wrapper): Check validity of pointer "new_item" before using.
author Rik <rik@octave.org>
date Tue, 08 Jan 2019 21:01:36 -0800
parents af476ac04cfd
children f1f8cd686fcd
files liboctave/system/lo-sysdep.cc
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/system/lo-sysdep.cc	Tue Jan 08 20:47:49 2019 -0800
+++ b/liboctave/system/lo-sysdep.cc	Tue Jan 08 21:01:36 2019 -0800
@@ -170,7 +170,8 @@
 
       char *new_item = static_cast<char *> (std::malloc (new_len));
 
-      sprintf (new_item, "%s=%s", name.c_str (), value.c_str ());
+      if (new_item)
+        sprintf (new_item, "%s=%s", name.c_str (), value.c_str ());
 
       // As far as I can see there's no way to distinguish between the
       // various errors; putenv doesn't have errno values.