From c8dd4456e077409cb694e7d54ce8ecec5deb237a Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 20 Jun 2018 17:14:53 +0200 Subject: [PATCH 1/4] Fix CID 1393240 (Missing return statement) This also fixes a compiler warning: unittest/progress_test.cc:59:9: warning: no return statement in function returning non-void [-Wreturn-type] Signed-off-by: Stefan Weil --- unittest/progress_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/progress_test.cc b/unittest/progress_test.cc index d2f879d3..b999b2c5 100644 --- a/unittest/progress_test.cc +++ b/unittest/progress_test.cc @@ -55,7 +55,7 @@ class QuickTest : public testing::Test { return instance->classicProgress( progress ); }; monitor.cancel = []( void* ths, int words ) -> bool { - ((ClassicMockProgressSink*)ths)->cancel( words ); + return ((ClassicMockProgressSink*)ths)->cancel(words); }; monitor.cancel_this = this; instance = this; From d6391ee811a1b0c5909fb6617c78c39903f4dfa6 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 20 Jun 2018 17:32:02 +0200 Subject: [PATCH 2/4] Fix CID 1393540 (Explicit null dereferenced) Coverity Scan does not like incrementing of a null pointer, so increment an index value instead of a pointer. Signed-off-by: Stefan Weil --- src/ccutil/scanutils.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ccutil/scanutils.cpp b/src/ccutil/scanutils.cpp index aeb16707..c64e0ba5 100644 --- a/src/ccutil/scanutils.cpp +++ b/src/ccutil/scanutils.cpp @@ -475,20 +475,22 @@ static int tvfscanf(FILE* stream, const char *format, va_list ap) { if (!(flags & FL_SPLAT)) { sarg = va_arg(ap, char *); } - char *sp = sarg; + unsigned length = 0; while (width--) { q = fgetc(stream); if (isspace(static_cast(q)) || q <= 0) { ungetc(q, stream); break; } - if (!(flags & FL_SPLAT)) *sp = q; - sp++; + if (!(flags & FL_SPLAT)) { + sarg[length] = q; + } + length++; } - if (sarg == sp) { + if (length == 0) { bail = BAIL_EOF; } else if (!(flags & FL_SPLAT)) { - *sp = '\0'; // Terminate output + sarg[length] = '\0'; // Terminate output converted++; } } From 2ceb2001861750c7a51a5a12c93b95e297629b4f Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 20 Jun 2018 19:28:04 +0200 Subject: [PATCH 3/4] Fix CID 1393244 and CID 1393244 (Uninitialized scalar variable) Signed-off-by: Stefan Weil --- src/classify/intfx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classify/intfx.cpp b/src/classify/intfx.cpp index 75a07a78..ce3801bb 100644 --- a/src/classify/intfx.cpp +++ b/src/classify/intfx.cpp @@ -354,7 +354,7 @@ static void ExtractFeaturesFromRun( denorm.NormTransform(root_denorm, prev_normed_pos, &prev_normed_pos); LLSQ points; LLSQ dirs; - FCOORD normed_pos; + FCOORD normed_pos(0.0f, 0.0f); int index = GatherPoints(outline, feature_length, denorm, root_denorm, start_index, end_index, &pos, &normed_pos, &points, &dirs); @@ -366,7 +366,7 @@ static void ExtractFeaturesFromRun( // accumulators. LLSQ next_points; LLSQ next_dirs; - FCOORD next_normed_pos; + FCOORD next_normed_pos(0.0f, 0.0f); index = GatherPoints(outline, feature_length, denorm, root_denorm, index, end_index, &pos, &next_normed_pos, &next_points, &next_dirs); From f482ebdca16c3a1da44dbbd4c28b7cdb6a8ec5b7 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 20 Jun 2018 19:34:06 +0200 Subject: [PATCH 4/4] Fix CID 1393243 (Uninitialized scalar field) Signed-off-by: Stefan Weil --- src/textord/colfind.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/textord/colfind.cpp b/src/textord/colfind.cpp index bf630d35..d7b27bee 100644 --- a/src/textord/colfind.cpp +++ b/src/textord/colfind.cpp @@ -84,7 +84,9 @@ ColumnFinder::ColumnFinder(int gridsize, min_gutter_width_(static_cast(kMinGutterWidthGrid * gridsize)), mean_column_gap_(tright.x() - bleft.x()), tabfind_aligned_gap_fraction_(aligned_gap_fraction), + deskew_(0.0f, 0.0f), reskew_(1.0f, 0.0f), rotation_(1.0f, 0.0f), rerotate_(1.0f, 0.0f), + text_rotation_(0.0f, 0.0f), best_columns_(nullptr), stroke_width_(nullptr), part_grid_(gridsize, bleft, tright), nontext_map_(nullptr), projection_(resolution),