diff base/Debug.cpp @ 986:e8e6c4e7437b

Correct some really stupid fixed-length string stuff, including a genuine stack overflow that causes a crash on OS/X for certain colour 3d plot data.
author Chris Cannam
date Mon, 29 Sep 2014 13:27:13 +0100
parents d002827b5896
children c49d52386cde
line wrap: on
line diff
--- a/base/Debug.cpp	Tue Sep 16 10:29:19 2014 +0100
+++ b/base/Debug.cpp	Mon Sep 29 13:27:13 2014 +0100
@@ -43,8 +43,9 @@
     QDir logdir(QString("%1/%2").arg(pfx).arg("log"));
 
     if (!prefix) {
-        prefix = new char[20];
-        sprintf(prefix, "[%lu]", (unsigned long)QCoreApplication::applicationPid());
+        prefix = strdup(QString("[%1]")
+                        .arg(QCoreApplication::applicationPid())
+                        .toLatin1().data());
         //!!! what to do if mkpath fails?
 	if (!logdir.exists()) logdir.mkpath(logdir.path());
     }