Skip to content

Commit 5ce88d7

Browse files
committed
pdfrenderer: Fix uninitialized local variables
Coverity bug reports: CID 1270405: Uninitialized scalar variable CID 1270408: Uninitialized scalar variable CID 1270409: Uninitialized scalar variable CID 1270410: Uninitialized scalar variable Those variables are set conditionally in the while loop and must keep their values in following iterations, so they must be declared outside of the loop. Signed-off-by: Stefan Weil <[email protected]>
1 parent 9f87c36 commit 5ce88d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/pdfrenderer.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
311311
pdf_str.add_str_double("", prec(height));
312312
pdf_str += " 0 0 cm /Im1 Do Q\n";
313313

314+
int line_x1 = 0;
315+
int line_y1 = 0;
316+
int line_x2 = 0;
317+
int line_y2 = 0;
318+
314319
ResultIterator *res_it = api->GetIterator();
315320
while (!res_it->Empty(RIL_BLOCK)) {
316321
if (res_it->IsAtBeginningOf(RIL_BLOCK)) {
@@ -319,7 +324,6 @@ char* TessPDFRenderer::GetPDFTextObjects(TessBaseAPI* api,
319324
new_block = true; // Every block will declare its affine matrix
320325
}
321326

322-
int line_x1, line_y1, line_x2, line_y2;
323327
if (res_it->IsAtBeginningOf(RIL_TEXTLINE)) {
324328
int x1, y1, x2, y2;
325329
res_it->Baseline(RIL_TEXTLINE, &x1, &y1, &x2, &y2);

0 commit comments

Comments
 (0)