Fix potentially ambiguous printf()
authorRobin Gareus <robin@gareus.org>
Thu, 23 Nov 2017 09:12:34 +0000 (10:12 +0100)
committerRobin Gareus <robin@gareus.org>
Thu, 23 Nov 2017 09:12:34 +0000 (10:12 +0100)
Not a real issue, since it's just supposed to be some unique number.
but still.

Reported by PVS-Studio - https://www.viva64.com/en/b/0540/

gtk2_ardour/luawindow.cc

index 89a1d387aa490cfdb1ea058c80a803842d8d1cfc..4e02cd2b20a15940ad593470a57aa78dab1e110c 100644 (file)
@@ -483,11 +483,12 @@ LuaWindow::save_script ()
 
        // 5) construct filename -- TODO ask user for name, ask to replace file.
        do {
+               char tme[80];
                char buf[80];
                time_t t = time(0);
                struct tm * timeinfo = localtime (&t);
-               strftime (buf, sizeof(buf), "%s%d", timeinfo);
-               sprintf (buf, "%s%ld", buf, random ()); // is this valid?
+               strftime (tme, sizeof(tme), "%s", timeinfo);
+               snprintf (buf, sizeof(buf), "%s%ld", tme, random ());
                MD5 md5;
                std::string fn = md5.digestString (buf);