-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 1106: [PATCH] Fixed potential usage of uninitialized bool varia… #9
Conversation
…ble in textord/tospace.cpp https://code.google.com/p/tesseract-ocr/issues/detail?id=1106 Reported by ettl.martin78, Feb 11, 2014 Please review the attached patch. It fixes a potential usage of an uninitialized bool variable ('fuzzy_sp'). The fix simply initialized the variable by default to 'FALSE'. Before the fix, the value of 'fuzzy_sp' was not set, but used in the else-branch in line 1107: else { prev_blanks = blanks; prev_fuzzy_sp = fuzzy_sp; prev_fuzzy_non = fuzzy_non; } Best regards and many thanks Feb 11, 2014 tesseract-ocr#1 ettl.martin78 The updated patch fixes two more uninitialized variable usages in the same function. Many thanks for reviewing.
@@ -932,6 +932,9 @@ ROW *Textord::make_prop_words( | |||
box_it.set_to_list (row->blob_list ()); | |||
word_it.set_to_list (&words); | |||
bol = TRUE; | |||
fuzzy_non = FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These initializations look redundant to me. They are already initialized at declaration time near line 894.
Having said that, I find the mix of declaration time and non-declaration initializations needlessly complex and think all of these later initializations should get rolled back up into the declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ray addressed that issue after Martin's bug report: commit 9708041 fixes all three cases, so this pull request can be closed.
Coverity report: CID 1164722 (#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
@orbitcowboy, |
Thanks Stefan. Somehow I missed that commit. |
The following code caused a crash when Tesseract was compiled with -ftrapv: 1259 int width = right - left; #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 #1 0x00007ffff665c231 in __GI_abort () at abort.c:79 #2 0x00007ffff69e34d8 in __subvsi3 () from /lib/x86_64-linux-gnu/libgcc_s.so.1 #3 0x000055555560c1c5 in tesseract::ColPartitionGrid::FindVPartitionPartners (this=0x55555717e3c0, to_the_left=true, part=0x5555571fa380) at ../../../src/textord/colpartitiongrid.cpp:1259 #4 0x000055555560bda0 in tesseract::ColPartitionGrid::FindPartitionPartners (this=0x55555717e3c0) at ../../../src/textord/colpartitiongrid.cpp:1196 #5 0x00005555555f52b6 in tesseract::ColumnFinder::FindBlocks (this=0x55555717e280, pageseg_mode=tesseract::PSM_AUTO, scaled_color=0x0, scaled_factor=-1, input_block=0x555555f91390, photo_mask_pix=0x555555f73300, thresholds_pix=0x555555f76290, grey_pix=0x555555f762e0, pixa_debug=0x7ffff7fc88d8, blocks=0x7fffffffd250, diacritic_blobs=0x7fffffffd330, to_blocks=0x7fffffffd328) at ../../../src/textord/colfind.cpp:431 #6 0x00005555555c240d in tesseract::Tesseract::AutoPageSeg (this=0x7ffff7fa5010, pageseg_mode=tesseract::PSM_AUTO, blocks=0x555555f761d0, to_blocks=0x7fffffffd328, diacritic_blobs=0x7fffffffd330, osd_tess=0x0, osr=0x7fffffffd6d0) at ../../../src/ccmain/pagesegmain.cpp:229 #7 0x00005555555c1ffd in tesseract::Tesseract::SegmentPage (this=0x7ffff7fa5010, input_file=0x555555f7bd90, blocks=0x555555f761d0, osd_tess=0x0, osr=0x7fffffffd6d0) at ../../../src/ccmain/pagesegmain.cpp:141 #8 0x0000555555582540 in tesseract::TessBaseAPI::FindLines (this=0x555555a9a580 <main::api>) at ../../../src/api/baseapi.cpp:2291 #9 0x000055555557ce42 in tesseract::TessBaseAPI::Recognize (this=0x555555a9a580 <main::api>, monitor=0x0) at ../../../src/api/baseapi.cpp:802 Signed-off-by: Stefan Weil <[email protected]>
The following code caused a crash when Tesseract was compiled with -ftrapv: 1259 int width = right - left; #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 tesseract-ocr#1 0x00007ffff665c231 in __GI_abort () at abort.c:79 tesseract-ocr#2 0x00007ffff69e34d8 in __subvsi3 () from /lib/x86_64-linux-gnu/libgcc_s.so.1 tesseract-ocr#3 0x000055555560c1c5 in tesseract::ColPartitionGrid::FindVPartitionPartners (this=0x55555717e3c0, to_the_left=true, part=0x5555571fa380) at ../../../src/textord/colpartitiongrid.cpp:1259 tesseract-ocr#4 0x000055555560bda0 in tesseract::ColPartitionGrid::FindPartitionPartners (this=0x55555717e3c0) at ../../../src/textord/colpartitiongrid.cpp:1196 tesseract-ocr#5 0x00005555555f52b6 in tesseract::ColumnFinder::FindBlocks (this=0x55555717e280, pageseg_mode=tesseract::PSM_AUTO, scaled_color=0x0, scaled_factor=-1, input_block=0x555555f91390, photo_mask_pix=0x555555f73300, thresholds_pix=0x555555f76290, grey_pix=0x555555f762e0, pixa_debug=0x7ffff7fc88d8, blocks=0x7fffffffd250, diacritic_blobs=0x7fffffffd330, to_blocks=0x7fffffffd328) at ../../../src/textord/colfind.cpp:431 tesseract-ocr#6 0x00005555555c240d in tesseract::Tesseract::AutoPageSeg (this=0x7ffff7fa5010, pageseg_mode=tesseract::PSM_AUTO, blocks=0x555555f761d0, to_blocks=0x7fffffffd328, diacritic_blobs=0x7fffffffd330, osd_tess=0x0, osr=0x7fffffffd6d0) at ../../../src/ccmain/pagesegmain.cpp:229 tesseract-ocr#7 0x00005555555c1ffd in tesseract::Tesseract::SegmentPage (this=0x7ffff7fa5010, input_file=0x555555f7bd90, blocks=0x555555f761d0, osd_tess=0x0, osr=0x7fffffffd6d0) at ../../../src/ccmain/pagesegmain.cpp:141 tesseract-ocr#8 0x0000555555582540 in tesseract::TessBaseAPI::FindLines (this=0x555555a9a580 <main::api>) at ../../../src/api/baseapi.cpp:2291 tesseract-ocr#9 0x000055555557ce42 in tesseract::TessBaseAPI::Recognize (this=0x555555a9a580 <main::api>, monitor=0x0) at ../../../src/api/baseapi.cpp:802 Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (tesseract-ocr#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (tesseract-ocr#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (tesseract-ocr#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
Coverity report: CID 1164722 (tesseract-ocr#9 of 9): Resource leak (RESOURCE_LEAK) 20. leaked_storage: Variable label32 going out of scope leaks the storage it points to. Signed-off-by: Stefan Weil <[email protected]>
…ble in textord/tospace.cpp
https://code.google.com/p/tesseract-ocr/issues/detail?id=1106
Reported by ettl.martin78, Feb 11, 2014
Please review the attached patch. It fixes a potential usage of an uninitialized bool variable ('fuzzy_sp'). The fix simply initialized the variable by default to 'FALSE'. Before the fix, the value of 'fuzzy_sp' was not set, but used in the else-branch in line 1107:
Best regards and many thanks
Feb 11, 2014
#1 ettl.martin78
The updated patch fixes two more uninitialized variable usages in the same function.
Many thanks for reviewing.
(http://web.archive.org/web/20150509223835/https://code.google.com/p/tesseract-ocr/issues/detail?id=1106)