mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
RAII: PB_LINE_IT::get_line(): was leaked inside POLY_BLOCK::fill()
This commit is contained in:
parent
8aa0a2dd48
commit
190584fec7
@ -18,6 +18,7 @@
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory> // std::unique_ptr
|
||||
#include "blckerr.h"
|
||||
#include "ocrblock.h"
|
||||
#include "stepblob.h"
|
||||
@ -380,9 +381,8 @@ void BLOCK::compute_row_margins() {
|
||||
TBOX row_box = row->bounding_box();
|
||||
int left_y = row->base_line(row_box.left()) + row->x_height();
|
||||
int left_margin;
|
||||
ICOORDELT_LIST *segments = lines.get_line(left_y);
|
||||
LeftMargin(segments, row_box.left(), &left_margin);
|
||||
delete segments;
|
||||
const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments_left(lines.get_line(left_y));
|
||||
LeftMargin(segments_left.get(), row_box.left(), &left_margin);
|
||||
|
||||
if (row_box.top() >= drop_cap_bottom) {
|
||||
int drop_cap_distance = row_box.left() - row->space() - drop_cap_right;
|
||||
@ -394,9 +394,8 @@ void BLOCK::compute_row_margins() {
|
||||
|
||||
int right_y = row->base_line(row_box.right()) + row->x_height();
|
||||
int right_margin;
|
||||
segments = lines.get_line(right_y);
|
||||
RightMargin(segments, row_box.right(), &right_margin);
|
||||
delete segments;
|
||||
const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments_right(lines.get_line(right_y));
|
||||
RightMargin(segments_right.get(), row_box.right(), &right_margin);
|
||||
row->set_lmargin(left_margin);
|
||||
row->set_rmargin(right_margin);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
**********************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <memory> // std::unique_ptr
|
||||
#include "allheaders.h"
|
||||
#include "blckerr.h"
|
||||
#include "pdblock.h"
|
||||
@ -140,9 +141,9 @@ Pix* PDBLK::render_mask(const FCOORD& rerotation, TBOX* mask_box) {
|
||||
// rasterized interior. (Runs of interior pixels on a line.)
|
||||
PB_LINE_IT *lines = new PB_LINE_IT(&image_block);
|
||||
for (int y = box.bottom(); y < box.top(); ++y) {
|
||||
ICOORDELT_LIST* segments = lines->get_line(y);
|
||||
const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments(lines->get_line(y));
|
||||
if (!segments->empty()) {
|
||||
ICOORDELT_IT s_it(segments);
|
||||
ICOORDELT_IT s_it(segments.get());
|
||||
// Each element of segments is a start x and x size of the
|
||||
// run of interior pixels.
|
||||
for (s_it.mark_cycle_pt(); !s_it.cycled_list(); s_it.forward()) {
|
||||
@ -154,7 +155,6 @@ Pix* PDBLK::render_mask(const FCOORD& rerotation, TBOX* mask_box) {
|
||||
xext, 1, PIX_SET, NULL, 0, 0);
|
||||
}
|
||||
}
|
||||
delete segments;
|
||||
}
|
||||
delete lines;
|
||||
} else {
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <memory> // std::unique_ptr
|
||||
#include "elst.h"
|
||||
#include "polyblk.h"
|
||||
|
||||
@ -273,7 +274,6 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
|
||||
inT16 y;
|
||||
inT16 width;
|
||||
PB_LINE_IT *lines;
|
||||
ICOORDELT_LIST *segments;
|
||||
ICOORDELT_IT s_it;
|
||||
|
||||
lines = new PB_LINE_IT (this);
|
||||
@ -281,9 +281,9 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
|
||||
|
||||
for (y = this->bounding_box ()->bottom ();
|
||||
y <= this->bounding_box ()->top (); y++) {
|
||||
segments = lines->get_line (y);
|
||||
const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments(lines->get_line (y));
|
||||
if (!segments->empty ()) {
|
||||
s_it.set_to_list (segments);
|
||||
s_it.set_to_list (segments.get());
|
||||
for (s_it.mark_cycle_pt (); !s_it.cycled_list (); s_it.forward ()) {
|
||||
// Note different use of ICOORDELT, x coord is x coord of pixel
|
||||
// at the start of line segment, y coord is length of line segment
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "scanedg.h"
|
||||
|
||||
#include <memory> // std::unique_ptr
|
||||
|
||||
#include "allheaders.h"
|
||||
#include "edgloop.h"
|
||||
|
||||
@ -93,7 +95,6 @@ void make_margins( //get a line
|
||||
inT16 y //line coord
|
||||
) {
|
||||
PB_LINE_IT *lines;
|
||||
ICOORDELT_LIST *segments; //bits of a line
|
||||
ICOORDELT_IT seg_it;
|
||||
inT32 start; //of segment
|
||||
inT16 xext; //of segment
|
||||
@ -101,9 +102,9 @@ void make_margins( //get a line
|
||||
|
||||
if (block->poly_block () != NULL) {
|
||||
lines = new PB_LINE_IT (block->poly_block ());
|
||||
segments = lines->get_line (y);
|
||||
const std::unique_ptr</*non-const*/ ICOORDELT_LIST> segments(lines->get_line (y));
|
||||
if (!segments->empty ()) {
|
||||
seg_it.set_to_list (segments);
|
||||
seg_it.set_to_list (segments.get());
|
||||
seg_it.mark_cycle_pt ();
|
||||
start = seg_it.data ()->x ();
|
||||
xext = seg_it.data ()->y ();
|
||||
@ -122,7 +123,6 @@ void make_margins( //get a line
|
||||
for (xindex = left; xindex < right; xindex++)
|
||||
pixels[xindex - left] = margin;
|
||||
}
|
||||
delete segments;
|
||||
delete lines;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user