kopia lustrzana https://gitlab.com/sane-project/backends
minor memory handling fixes
- check success after calloc() - fix memleak in find_start_line()merge-requests/1/head
rodzic
ce0ba551ca
commit
255c83e1d7
|
@ -82,8 +82,7 @@ static SANE_Bool low_is_home_line (unsigned char *buffer);
|
||||||
static SANE_Status low_get_start_loc (SANE_Int resolution,
|
static SANE_Status low_get_start_loc (SANE_Int resolution,
|
||||||
SANE_Int * vert_start,
|
SANE_Int * vert_start,
|
||||||
SANE_Int * hor_start,
|
SANE_Int * hor_start,
|
||||||
SANE_Int offset,
|
SANE_Int offset, Lexmark_Device * dev);
|
||||||
Lexmark_Device * dev);
|
|
||||||
static void low_rewind (Lexmark_Device * dev, SANE_Byte * regs);
|
static void low_rewind (Lexmark_Device * dev, SANE_Byte * regs);
|
||||||
static SANE_Status low_start_mvmt (SANE_Int devnum);
|
static SANE_Status low_start_mvmt (SANE_Int devnum);
|
||||||
static SANE_Status low_stop_mvmt (SANE_Int devnum);
|
static SANE_Status low_stop_mvmt (SANE_Int devnum);
|
||||||
|
@ -419,7 +418,9 @@ lexmark_low_wake_up (Lexmark_Device * dev)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifdef DEEP_DEBUG
|
#ifdef DEEP_DEBUG
|
||||||
static void write_pnm_file(char *title, int pixels, int lines, int color, unsigned char *data)
|
static void
|
||||||
|
write_pnm_file (char *title, int pixels, int lines, int color,
|
||||||
|
unsigned char *data)
|
||||||
{
|
{
|
||||||
FILE *fdbg;
|
FILE *fdbg;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -1781,6 +1782,10 @@ sanei_lexmark_low_search_home_fwd (Lexmark_Device * dev)
|
||||||
|
|
||||||
/* create buffer for scan data */
|
/* create buffer for scan data */
|
||||||
buffer = calloc (2500, sizeof (char));
|
buffer = calloc (2500, sizeof (char));
|
||||||
|
if (buffer == NULL)
|
||||||
|
{
|
||||||
|
return SANE_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell the scanner to send the data */
|
/* Tell the scanner to send the data */
|
||||||
/* Write: 91 00 09 c4 */
|
/* Write: 91 00 09 c4 */
|
||||||
|
@ -1997,6 +2002,10 @@ sanei_lexmark_low_search_home_bwd (Lexmark_Device * dev)
|
||||||
|
|
||||||
/* create buffer to hold up to 10 lines of scan data */
|
/* create buffer to hold up to 10 lines of scan data */
|
||||||
buffer = calloc (10 * 2500, sizeof (char));
|
buffer = calloc (10 * 2500, sizeof (char));
|
||||||
|
if (buffer == NULL)
|
||||||
|
{
|
||||||
|
return SANE_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
home_line_count = 0;
|
home_line_count = 0;
|
||||||
in_home_region = SANE_FALSE;
|
in_home_region = SANE_FALSE;
|
||||||
|
@ -2468,6 +2477,10 @@ sanei_lexmark_low_find_start_line (Lexmark_Device * dev)
|
||||||
|
|
||||||
/* create buffer for scan data */
|
/* create buffer for scan data */
|
||||||
buffer = calloc (5192, sizeof (char));
|
buffer = calloc (5192, sizeof (char));
|
||||||
|
if (buffer == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell the scanner to send the data */
|
/* Tell the scanner to send the data */
|
||||||
/* Write: 91 00 14 48 */
|
/* Write: 91 00 14 48 */
|
||||||
|
@ -2546,14 +2559,15 @@ sanei_lexmark_low_find_start_line (Lexmark_Device * dev)
|
||||||
}
|
}
|
||||||
} /* end for buffer */
|
} /* end for buffer */
|
||||||
|
|
||||||
|
free (buffer);
|
||||||
DBG (2, "sanei_lexmark_low_find_start_line: end.\n");
|
DBG (2, "sanei_lexmark_low_find_start_line: end.\n");
|
||||||
return whiteLineCount;
|
return whiteLineCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SANE_Status
|
SANE_Status
|
||||||
sanei_lexmark_low_set_scan_regs (Lexmark_Device * dev, SANE_Int resolution, SANE_Int offset,
|
sanei_lexmark_low_set_scan_regs (Lexmark_Device * dev, SANE_Int resolution,
|
||||||
SANE_Bool calibrated)
|
SANE_Int offset, SANE_Bool calibrated)
|
||||||
{
|
{
|
||||||
SANE_Bool isColourScan;
|
SANE_Bool isColourScan;
|
||||||
|
|
||||||
|
@ -4036,7 +4050,8 @@ sanei_lexmark_low_read_scan_data (SANE_Byte * data, SANE_Int size,
|
||||||
status = low_poll_data (dev->devnum);
|
status = low_poll_data (dev->devnum);
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
DBG (1, "sanei_lexmark_low_read_scan_data: time-out while waiting for data.\n");
|
DBG (1,
|
||||||
|
"sanei_lexmark_low_read_scan_data: time-out while waiting for data.\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4676,7 +4691,8 @@ sanei_lexmark_low_offset_calibration (Lexmark_Device * dev)
|
||||||
}
|
}
|
||||||
average = average_area (regs, data, pixels, lines, &ra, &ga, &ba);
|
average = average_area (regs, data, pixels, lines, &ra, &ga, &ba);
|
||||||
#ifdef DEEP_DEBUG
|
#ifdef DEEP_DEBUG
|
||||||
write_pnm_file("offset-final.pnm",pixels,lines,rts88xx_is_color (regs),data);
|
write_pnm_file ("offset-final.pnm", pixels, lines, rts88xx_is_color (regs),
|
||||||
|
data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this "law" is a guess, may (should?) be changed ... */
|
/* this "law" is a guess, may (should?) be changed ... */
|
||||||
|
@ -4763,8 +4779,7 @@ sanei_lexmark_low_gain_calibration (Lexmark_Device * dev)
|
||||||
|| (!rts88xx_is_color (regs)
|
|| (!rts88xx_is_color (regs)
|
||||||
&& (ga < dev->sensor->gray_gain_target))) && (i < 25))
|
&& (ga < dev->sensor->gray_gain_target))) && (i < 25))
|
||||||
{
|
{
|
||||||
status =
|
status = low_simple_scan (dev, regs, sx, pixels, yoffset, lines, &data);
|
||||||
low_simple_scan (dev, regs, sx, pixels, yoffset, lines, &data);
|
|
||||||
if (status != SANE_STATUS_GOOD)
|
if (status != SANE_STATUS_GOOD)
|
||||||
{
|
{
|
||||||
DBG (1,
|
DBG (1,
|
||||||
|
@ -4918,7 +4933,8 @@ sanei_lexmark_low_shading_calibration (Lexmark_Device * dev)
|
||||||
DBG (7, "sanei_lexmark_low_shading_calibration: yoffset=%d.\n", yoffset);
|
DBG (7, "sanei_lexmark_low_shading_calibration: yoffset=%d.\n", yoffset);
|
||||||
|
|
||||||
#ifdef DEEP_DEBUG
|
#ifdef DEEP_DEBUG
|
||||||
write_pnm_file("shading.pnm",pixels,lines,rts88xx_is_color (regs),data);
|
write_pnm_file ("shading.pnm", pixels, lines, rts88xx_is_color (regs),
|
||||||
|
data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* computes coefficients */
|
/* computes coefficients */
|
||||||
|
@ -4985,7 +5001,8 @@ sanei_lexmark_low_shading_calibration (Lexmark_Device * dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEEP_DEBUG
|
#ifdef DEEP_DEBUG
|
||||||
write_pnm_file("shading_bwd.pnm",pixels,lines,rts88xx_is_color (regs),data);
|
write_pnm_file ("shading_bwd.pnm", pixels, lines, rts88xx_is_color (regs),
|
||||||
|
data);
|
||||||
#endif
|
#endif
|
||||||
free (data);
|
free (data);
|
||||||
|
|
||||||
|
@ -5084,9 +5101,9 @@ sanei_lexmark_low_assign_sensor (Lexmark_Device * dev)
|
||||||
/* assign model description, based on USB id, and register content when
|
/* assign model description, based on USB id, and register content when
|
||||||
* available */
|
* available */
|
||||||
SANE_Status
|
SANE_Status
|
||||||
sanei_lexmark_low_assign_model (Lexmark_Device * dev, SANE_String_Const devname,
|
sanei_lexmark_low_assign_model (Lexmark_Device * dev,
|
||||||
SANE_Int vendor, SANE_Int product,
|
SANE_String_Const devname, SANE_Int vendor,
|
||||||
SANE_Byte mainboard)
|
SANE_Int product, SANE_Byte mainboard)
|
||||||
{
|
{
|
||||||
int dn;
|
int dn;
|
||||||
SANE_Bool found = SANE_FALSE;
|
SANE_Bool found = SANE_FALSE;
|
||||||
|
@ -5133,8 +5150,7 @@ sanei_lexmark_low_assign_model (Lexmark_Device * dev, SANE_String_Const devname,
|
||||||
dev->model = model_list[dn];
|
dev->model = model_list[dn];
|
||||||
dev->sane.type = "flatbed scanner";
|
dev->sane.type = "flatbed scanner";
|
||||||
|
|
||||||
DBG (3, "sanei_lexmark_low_assign_model: assigned %s\n",
|
DBG (3, "sanei_lexmark_low_assign_model: assigned %s\n", dev->model.model);
|
||||||
dev->model.model);
|
|
||||||
|
|
||||||
/* init sensor data */
|
/* init sensor data */
|
||||||
return sanei_lexmark_low_assign_sensor (dev);
|
return sanei_lexmark_low_assign_sensor (dev);
|
||||||
|
|
Ładowanie…
Reference in New Issue