Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/text/src/erfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@ class dissimilarity {
N(_Num),
members(_members),
postprocessfn(NULL),
distfn(NULL),
V(NULL)
{
switch (method) {
Expand Down
4 changes: 2 additions & 2 deletions modules/text/src/ocr_hmm_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class OCRHMMDecoderImpl : public OCRHMMDecoder
vector<int> spaces_start;
vector<int> spaces_end;
int space_count=0;
int last_one_idx;
int last_one_idx=0;

int s_init = 0, s_end=vector_w.cols;
for (int s=0; s<vector_w.cols; s++)
Expand Down Expand Up @@ -456,7 +456,7 @@ class OCRHMMDecoderImpl : public OCRHMMDecoder
vector<int> spaces_start;
vector<int> spaces_end;
int space_count=0;
int last_one_idx;
int last_one_idx=0;

int s_init = 0, s_end=vector_w.cols;
for (int s=0; s<vector_w.cols; s++)
Expand Down
14 changes: 9 additions & 5 deletions modules/wechat_qrcode/src/zxing/common/bytematrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ void ByteMatrix::init(int _width, int _height) {
}
}

ByteMatrix::ByteMatrix(int dimension) { init(dimension, dimension); }
ByteMatrix::ByteMatrix(int dimension) : bytes(nullptr) { init(dimension, dimension); }

ByteMatrix::ByteMatrix(int _width, int _height) { init(_width, _height); }
ByteMatrix::ByteMatrix(int _width, int _height) : bytes(nullptr) { init(_width, _height); }

ByteMatrix::ByteMatrix(int _width, int _height, ArrayRef<char> source) {
ByteMatrix::ByteMatrix(int _width, int _height, ArrayRef<char> source) : bytes(nullptr) {
init(_width, _height);
int size = _width * _height;
memcpy(&bytes[0], &source[0], size);

if( bytes != nullptr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes just initialized at line 33 with nullptr. Most probably it's a typo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review !

bytes just initialized at line 33 with nullptr. Most probably it's a typo.

bytes are allocated in init() function.

ByteMatrix::ByteMatrix(int _width, int _height, ArrayRef<char> source) : bytes(nullptr) {
    init(_width, _height);

    if( bytes != nullptr)
    {
        const size_t size = _width * _height;
        memcpy(&bytes[0], &source[0], size);
    }
}

But If one of _height and/or _width is less than 1 at (1) , bytes will not be allocated and keeps nullptr at (2).

void ByteMatrix::init(int _width, int _height) {
    if (_width < 1 || _height < 1) {  // (1)
        return;
    }
    this->width = _width;
    this->height = _height;
    bytes = new unsigned char[width * height]; // (2)
    row_offsets = new int[height];
    row_offsets[0] = 0;
    for (int i = 1; i < height; i++) {
        row_offsets[i] = row_offsets[i - 1] + width;
    }
}

{
const size_t size = _width * _height;
memcpy(&bytes[0], &source[0], size);
}
}

ByteMatrix::~ByteMatrix() {
Expand Down
Loading