misc: Fix a small pile of leaks and unintialized issues.
This commit is contained in:
parent
1d5d7853c5
commit
eb4fc21990
|
@ -1240,7 +1240,13 @@ bypass:
|
|||
|
||||
if (!fname) {
|
||||
if (uri)
|
||||
fprintf(stderr, "ERROR: No input file specified\n");
|
||||
ERROR("ERROR: No input file specified\n");
|
||||
goto done_claimed;
|
||||
}
|
||||
|
||||
if (ncopies < 1) {
|
||||
ERROR("ERROR: need to have at least 1 copy!\n");
|
||||
ret = CUPS_BACKEND_FAILED;
|
||||
goto done_claimed;
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1256,7 @@ bypass:
|
|||
if (data_fd < 0) {
|
||||
perror("ERROR:Can't open input file");
|
||||
ret = CUPS_BACKEND_FAILED;
|
||||
goto done;
|
||||
goto done_claimed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1266,7 +1272,7 @@ bypass:
|
|||
if (i < 0) {
|
||||
perror("ERROR:Can't open input");
|
||||
ret = CUPS_BACKEND_FAILED;
|
||||
goto done;
|
||||
goto done_claimed;
|
||||
}
|
||||
|
||||
/* Ignore SIGPIPE */
|
||||
|
|
|
@ -194,13 +194,16 @@ static int kodak6800_get_mediainfo(struct kodak6800_ctx *ctx)
|
|||
/* Issue command and get response */
|
||||
if ((ret = kodak6800_do_cmd(ctx, req, sizeof(req),
|
||||
media, MAX_MEDIA_LEN,
|
||||
&num)))
|
||||
&num))) {
|
||||
free(media);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Validate proper response */
|
||||
if (media->hdr != CMD_CODE_OK ||
|
||||
media->null[0] != 0x00) {
|
||||
ERROR("Unexpected response from media query!\n");
|
||||
free(media);
|
||||
return CUPS_BACKEND_STOP;
|
||||
}
|
||||
ctx->media_type = media->type;
|
||||
|
@ -809,11 +812,14 @@ static int kodak6800_read_parse(void *vctx, const void **vjob, int data_fd, int
|
|||
/* Read in then validate header */
|
||||
ret = read(data_fd, &hdr, sizeof(hdr));
|
||||
if (ret < 0 || ret != sizeof(hdr)) {
|
||||
if (ret == 0)
|
||||
if (ret == 0) {
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, 0, (int)sizeof(hdr));
|
||||
perror("ERROR: Read failed");
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
if (hdr.hdr[0] != 0x03 ||
|
||||
|
@ -822,6 +828,7 @@ static int kodak6800_read_parse(void *vctx, const void **vjob, int data_fd, int
|
|||
hdr.hdr[3] != 0x48 ||
|
||||
hdr.hdr[4] != 0x43) {
|
||||
ERROR("Unrecognized data format!\n");
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
|
||||
|
@ -829,6 +836,7 @@ static int kodak6800_read_parse(void *vctx, const void **vjob, int data_fd, int
|
|||
uint16_t cols = be16_to_cpu(hdr.columns);
|
||||
if (rows != 1240 && rows != 2434 && rows != 2140 && !ctx->supports_sub4x6) {
|
||||
ERROR("Printer Firmware does not support non-4x6/8x6/5x7 prints, please upgrade!\n");
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
|
||||
|
@ -836,6 +844,7 @@ static int kodak6800_read_parse(void *vctx, const void **vjob, int data_fd, int
|
|||
job->databuf = malloc(job->datalen);
|
||||
if (!job->databuf) {
|
||||
ERROR("Memory allocation failure!\n");
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_RETRY_CURRENT;
|
||||
}
|
||||
|
||||
|
@ -855,6 +864,7 @@ static int kodak6800_read_parse(void *vctx, const void **vjob, int data_fd, int
|
|||
ERROR("Read failed (%d/%d/%d)\n",
|
||||
ret, remain, job->datalen);
|
||||
perror("ERROR: Read failed");
|
||||
sinfonia_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
ptr += ret;
|
||||
|
|
|
@ -654,6 +654,7 @@ static int magicard_read_parse(void *vctx, const void **vjob, int data_fd, int c
|
|||
/* Safety valve */
|
||||
if (strlen(ptr) + job->datalen > MAX_HEADERS_LEN) {
|
||||
ERROR("headers too long, bogus job!\n");
|
||||
magicard_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
|
||||
|
|
|
@ -403,6 +403,8 @@ int sinfonia_getfwinfo(struct sinfonia_usbdev *usbh)
|
|||
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO);
|
||||
cmd.hdr.len = cpu_to_le16(1);
|
||||
|
||||
resp.hdr.payload_len = 0;
|
||||
|
||||
INFO("FW Information:\n");
|
||||
|
||||
for (i = FWINFO_TARGET_MAIN_BOOT ; i <= FWINFO_TARGET_PRINT_TABLES ; i++) {
|
||||
|
@ -442,6 +444,8 @@ int sinfonia_geterrorlog(struct sinfonia_usbdev *usbh)
|
|||
cmd.cmd = cpu_to_le16(SINFONIA_CMD_ERRORLOG);
|
||||
cmd.len = cpu_to_le16(0);
|
||||
|
||||
resp.hdr.payload_len = 0;
|
||||
|
||||
if ((ret = sinfonia_docmd(usbh,
|
||||
(uint8_t*)&cmd, sizeof(cmd),
|
||||
(uint8_t*)&resp, sizeof(resp),
|
||||
|
@ -500,6 +504,8 @@ int sinfonia_gettonecurve(struct sinfonia_usbdev *usbh, int type, char *fname)
|
|||
cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_READTONE);
|
||||
cmd.hdr.len = cpu_to_le16(1);
|
||||
|
||||
resp.hdr.payload_len = 0;
|
||||
|
||||
INFO("Dump %s Tone Curve to '%s'\n", sinfonia_tonecurve_statuses(type), fname);
|
||||
|
||||
if ((ret = sinfonia_docmd(usbh,
|
||||
|
@ -509,6 +515,9 @@ int sinfonia_gettonecurve(struct sinfonia_usbdev *usbh, int type, char *fname)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct sinfonia_readtone_resp) - sizeof(struct sinfonia_status_hdr)))
|
||||
return -2;
|
||||
|
||||
resp.total_size = le16_to_cpu(resp.total_size);
|
||||
|
||||
data = malloc(resp.total_size * 2);
|
||||
|
|
|
@ -398,6 +398,7 @@ static int upd_read_parse(void *vctx, const void **vjob, int data_fd, int copies
|
|||
{
|
||||
ERROR("Job data length mismatch (%u vs %d)!\n",
|
||||
job->imglen, job->rows * job->cols * ctx->native_bpp);
|
||||
upd_cleanup_job(job);
|
||||
return CUPS_BACKEND_CANCEL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue