Bug in FormulaDelegate : string copy was made in a wrong way

This commit is contained in:
2017-01-01 17:34:56 +01:00
parent 320d8689f6
commit d046f4e399
2 changed files with 10 additions and 7 deletions

View File

@@ -23,6 +23,7 @@
#include "FormulaDelegate.hpp"
#include <ParseExp.hpp>
#include "../wxUI.hpp"
#include <cstring>
#include <iostream>
QWidget * FormulaDelegate::createEditor (QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
@@ -38,17 +39,17 @@ void FormulaDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
double res = 0.0;
QString value = line->text();
struct ParseExp::parse_opt opt, *r;
const char* c;
char* str, *str2;
bool ok;
std::string ss;
value = value.trimmed();
if (value.startsWith("="))
{
value = value.replace(",", ".");
c = value.toStdString().c_str();
str2 = str = new char[strlen(c)];
strcpy(str, c+1);
ss = value.toStdString();
str2 = str = new char[ss.length()];
std::strcpy(str, ss.c_str()+1);
memset(&opt, 0, sizeof(opt));
r = &opt;
try {