Skip to content

Commit ba7742a

Browse files
committed
Fix undefined behavior (new size_t[0]), typos in layout
1 parent 7996ca6 commit ba7742a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

libhdt/src/util/Histogram.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Histogram {
2828

2929
Histogram() :
3030
Start(0), nBins_by_interval(0), nBins(0),
31-
freq(new size_t[0]) {
31+
freq(new size_t[1]) { // size_t[0] is undefined behavior
3232
reset();
3333
}
3434

@@ -69,7 +69,7 @@ class Histogram {
6969
delete[] freq;
7070
}
7171

72-
/** operator=
72+
/** operator=
7373
* Set this histogram equal to another.
7474
* @param other Description of the param.
7575
* @return The expected result.
@@ -81,9 +81,9 @@ class Histogram {
8181
if (nBins != other.nBins) {
8282
nBins = other.nBins;
8383
delete[] freq;
84-
freq = new size_t[nBins];
84+
freq = new size_t[nBins];
8585
}
86-
for (size_t i(0); i < nBins; ++i)
86+
for (size_t i(0); i < nBins; ++i)
8787
freq[i] = other.freq[i];
8888
}
8989
return *this;

0 commit comments

Comments
 (0)