Skip to content

Commit

Permalink
Merge pull request bitcoin#12 from CryptAxe/master
Browse files Browse the repository at this point in the history
More memory safety checks
  • Loading branch information
psztorc committed Nov 30, 2015
2 parents 4b52b47 + f6bf1bf commit 9880cb9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Hivemind Core integration/staging tree
=====================================

[http://www.bitcoinhivemind.com](http://www.bitcoinhivemind.com)
[http://www.bitcoin-hivemind.com](http://www.bitcoin-hivemind.com)

What is Hivemind?
----------------
Expand Down
17 changes: 12 additions & 5 deletions src/linalg/src/tc_mat.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ tc_mat_svd(
threshold = fabs(D->a[i][i+1]);
threshold *= 1e-12;
const double zero_threshold = 0.1 * threshold;
/* Always reindex the components so that
* D so that has the form
/* Always reindex the components so that D has the form
* [D1, 0] where D1 is diagonal and
* [ 0,D2] D2 is bidiagonal
* Let i0 be the starting index of D2
Expand Down Expand Up @@ -536,28 +535,36 @@ tc_mat_svd(
}
i1++;
}

/* move (i0,i1-1) down, i1 -> i0 */
for(uint32_t j=0; j < D->nr; j++) {
double tmp = V->a[i1][j];
for(uint32_t k=i1; k > i0; k--)
V->a[k][j] = V->a[k-1][j];
V->a[i0][j] = tmp;
}

for(uint32_t j=0; j < D->nr; j++) {
double tmp = U->a[j][i1];
for(uint32_t k=i1; k > i0; k--)
U->a[j][k] = U->a[j][k-1];
U->a[j][i0] = tmp;
}

uint32_t ir = i1;
if (ir+1 == D->nr)
ir--;
double tmp = D->a[i1][i1];
double tmp1 = D->a[i1][i1+1];
double tmp1 = D->a[i1][ir+1];

for(uint32_t k=i1; k > i0; k--) {
D->a[k][k] = D->a[k-1][k-1];
if (k+1 < D->nc)
D->a[k][k+1] = D->a[k-1][k];
}

D->a[i0][i0] = tmp;
D->a[i0][i0+1] = tmp1;
D->a[i0][ir+1] = tmp1;
i0++;
}
/* For any zeros on the superdiagonal, move the
Expand Down Expand Up @@ -855,7 +862,7 @@ tc_wgt_prin_comp(
for(uint32_t i=0; i < M->nr; i++)
x[i][j] = M->a[i][j] - avg;
}
/* wCMV = weighted covariance matrix of M */
/* wCVM = weighted covariance matrix of M */
double wgts2 = 0.0;
for(uint32_t i=0; i < M->nr; i++)
wgts2 += wgt->a[i][0] * wgt->a[i][0];
Expand Down
1 change: 0 additions & 1 deletion src/qt/resolvevotedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ ResolveVoteDialog::ResolveVoteDialog(QWidget *parent)
vi1layout->addWidget(inputTableView);

/* vo1layout (output) */

QTabWidget *tabs = new QTabWidget();
QWidget *dataTab = new QWidget();
tabs->addTab(dataTab, tr("Data"));
Expand Down
17 changes: 9 additions & 8 deletions src/qt/resolvevoteinputtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,19 @@ bool ResolveVoteInputTableModel::setData(const QModelIndex &index, const QVarian
if (!index.isValid())
return false;

const char *str;
if (value.isNull())
return false;

/* Accepted input types for QVariant "value" */
bool isNA = false;
double dvalue = 0.0;

if (value.isNull()) {
return false;
if (value.toString() == "NA") {
isNA = true;
} else {
str = value.toString().toStdString().c_str();
dvalue = value.toDouble();
}

bool isNA = (strstr(str, "NA"))? true: false;
double dvalue = atof(str);

int row = index.row();
int col = index.column();
if ((row < 3+(int)(*voteptr)->nr)
Expand Down Expand Up @@ -197,4 +199,3 @@ bool ResolveVoteInputTableModel::setData(const QModelIndex &index, const QVarian
}
return false;
}

0 comments on commit 9880cb9

Please sign in to comment.