Commit 285d83ad authored by Huff, Israel's avatar Huff, Israel
Browse files

- fortify changes

parent c608b3ea
Pipeline #67099 failed with stages
in 5 minutes and 40 seconds
......@@ -132,8 +132,8 @@ std::string remove_extra_whitespace(const std::string &inputStr)
struct std::tm utc_to_time(const std::string &time, int &zone, int &daylight)
{
int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
int count = sscanf(time.c_str(), "%d-%d-%dT%d:%d:%d-%d:%d", &year, &month,
&day, &hour, &minute, &second, &zone, &daylight);
sscanf(time.c_str(), "%d-%d-%dT%d:%d:%d-%d:%d", &year, &month, &day, &hour,
&minute, &second, &zone, &daylight);
radix_line("utc_to_time elements: " << count);
struct std::tm res;
res.tm_year = year;
......
......@@ -71,9 +71,10 @@ std::string computer_name()
char *hostname;
#ifndef _WIN32
hostname = new char[256];
hostname[255] = '\0';
if (gethostname(hostname, 256) != 0)
{
strcpy(hostname, "Unknown");
strncpy(hostname, "Unknown", 255);
}
std::string result(hostname);
delete[] hostname;
......@@ -485,6 +486,7 @@ long get_process_memory()
char buffer[128];
strncpy(buffer, line.substr(6).c_str(),
std::min(sizeof(buffer), line.size() - 6));
buffer[127] = '\0';
caddr_t context = nullptr, token = strtok_r(buffer, " \t", &context);
if (token != nullptr) result = long(atoi(token)) * 1024L;
......
......@@ -19,7 +19,8 @@ class NavigationActionManager::PImpl
NavigationActionManager::PImpl::~PImpl() {}
NavigationActionManager::NavigationActionManager(QObject *parent)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: QObject(parent)
, p(new PImpl(), [](PImpl *impl) { delete impl; })
{
}
......
......@@ -19,25 +19,27 @@ class NavigationItem::PImpl
NavigationItem::PImpl::~PImpl() { qDeleteAll(children); }
NavigationItem::NavigationItem(QVariant data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
p->data.append(data);
}
NavigationItem::NavigationItem(QList<QVariant> data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
p->data = data;
}
NavigationItem::NavigationItem(NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
}
void NavigationItem::deleter(PImpl *impl) { delete impl; }
int NavigationItem::type() const { return p->type; }
void NavigationItem::setType(int type) { p->type = type; }
......
......@@ -30,6 +30,7 @@ class RADIX_PUBLIC NavigationItem
private:
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
};
} // namespace radix
......
......@@ -21,11 +21,13 @@ NavigationModel::PImpl::~PImpl()
}
NavigationModel::NavigationModel(QObject* parent)
: QAbstractItemModel(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; })
, p(new PImpl(), deleter)
{
p->root = new NavigationItem();
}
void NavigationModel::deleter(PImpl* impl) { delete impl; }
QVariant NavigationModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) return QVariant();
......
......@@ -38,6 +38,7 @@ class RADIX_PUBLIC NavigationModel : public QAbstractItemModel
private:
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
};
} // namespace radix
......
......@@ -34,10 +34,12 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel::PImpl
NavigationItemSortFilterProxyModel::NavigationItemSortFilterProxyModel(
QObject* parent)
: QSortFilterProxyModel(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; })
, p(new PImpl(), deleter)
{
}
void NavigationItemSortFilterProxyModel::deleter(PImpl* impl) { delete impl; }
bool NavigationItemSortFilterProxyModel::accepts(const QModelIndex& index) const
{
const QString& text = index.data().toString();
......@@ -85,12 +87,14 @@ class RADIX_PUBLIC NavigationWidget::PImpl
NavigationWidget::NavigationWidget(QWidget* parent)
: QWidget(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; })
, p(new PImpl(), deleter)
{
initMembers();
initLayout();
}
void NavigationWidget::deleter(PImpl* impl) { delete impl; }
NavigationModel* NavigationWidget::navigationModel() { return p->model; }
NavigationActionManager* NavigationWidget::navigationActionManager()
......
......@@ -22,7 +22,8 @@ class NavigationItem;
class NavigationModel;
class NavigationActionManager;
class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyModel
class RADIX_PUBLIC NavigationItemSortFilterProxyModel
: public QSortFilterProxyModel
{
Q_OBJECT
......@@ -39,6 +40,7 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyM
bool accepts(const QModelIndex& index) const;
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
};
class RADIX_PUBLIC NavigationWidget : public QWidget
......@@ -73,6 +75,7 @@ class RADIX_PUBLIC NavigationWidget : public QWidget
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
};
} // namespace radix
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment