Mercurial > octave
diff libgui/graphics/Table.cc @ 26467:6595716a7f33 stable
Table.cc: Fix static analyzer detected issues (bug #55347).
* Table.cc (attempt_type_conversion): Fix lifetime issue by storing C++ string
in variable. Use portable format identifiers for int64_t and uint64_t.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 06 Jan 2019 16:41:20 +0100 |
parents | 2d9ae06f621b |
children | 83857449f3da |
line wrap: on
line diff
--- a/libgui/graphics/Table.cc Sun Jan 06 15:05:29 2019 +0100 +++ b/libgui/graphics/Table.cc Sun Jan 06 16:41:20 2019 +0100 @@ -353,7 +353,8 @@ { \ ctype val; \ int n; \ - const char *c_str = ov.string_value ().c_str (); \ + const std::string cxx_str = ov.string_value (); \ + const char *c_str = cxx_str.c_str (); \ int error = sscanf (c_str, format, &val, &n); \ if (error != 1 || c_str[n]) \ { \ @@ -364,14 +365,14 @@ if (old_value.is_string ()) retval = ov; - SCANF_AND_CONVERT(int8, int64_t, "%jd %n") - SCANF_AND_CONVERT(uint8, uint64_t, "%ju %n") - SCANF_AND_CONVERT(int16, int64_t, "%jd %n") - SCANF_AND_CONVERT(uint16, uint64_t, "%ju %n") - SCANF_AND_CONVERT(int32, int64_t, "%jd %n") - SCANF_AND_CONVERT(uint32, uint64_t, "%ju %n") - SCANF_AND_CONVERT(int64, int64_t, "%jd %n") - SCANF_AND_CONVERT(uint64, uint64_t, "%ju %n") + SCANF_AND_CONVERT(int8, int64_t, "%" PRId64 " %n") + SCANF_AND_CONVERT(uint8, uint64_t, "%" PRIu64 " %n") + SCANF_AND_CONVERT(int16, int64_t, "%" PRId64 " %n") + SCANF_AND_CONVERT(uint16, uint64_t, "%" PRIu64 " %n") + SCANF_AND_CONVERT(int32, int64_t, "%" PRId64 " %n") + SCANF_AND_CONVERT(uint32, uint64_t, "%" PRIu64 " %n") + SCANF_AND_CONVERT(int64, int64_t, "%" PRId64 " %n") + SCANF_AND_CONVERT(uint64, uint64_t, "%" PRIu64 " %n") #undef SCANF_AND_CONVERT