# HG changeset patch # User Chris Cannam # Date 1411993633 -3600 # Node ID e8e6c4e7437bf7d1a9a5bf937b53d20de99fdf89 # Parent f073d924a7c3153ab822a4a9f4522467c85af0db 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. diff -r f073d924a7c3 -r e8e6c4e7437b base/Debug.cpp --- 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()); } diff -r f073d924a7c3 -r e8e6c4e7437b data/fft/FFTDataServer.cpp --- a/data/fft/FFTDataServer.cpp Tue Sep 16 10:29:19 2014 +0100 +++ b/data/fft/FFTDataServer.cpp Mon Sep 29 13:27:13 2014 +0100 @@ -1428,18 +1428,14 @@ int fftSize, bool polar) { - char buffer[200]; - - sprintf(buffer, "%u-%u-%u-%u-%u-%u%s", - (unsigned int)XmlExportable::getObjectExportId(model), - (unsigned int)(channel + 1), - (unsigned int)windowType, - (unsigned int)windowSize, - (unsigned int)windowIncrement, - (unsigned int)fftSize, - polar ? "-p" : "-r"); - - return buffer; + return QString("%1-%2-%3-%4-%5-%6%7") + .arg(XmlExportable::getObjectExportId(model)) + .arg(channel + 1) + .arg((int)windowType) + .arg(windowSize) + .arg(windowIncrement) + .arg(fftSize) + .arg(polar ? "-p" : "-r"); } void