Skip to content

Commit 9a132cb

Browse files
committed
Free, close, and unlink files when failure happens
Remove freeing the free list.
1 parent 7f99d0c commit 9a132cb

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

backend/ipp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,12 +1400,18 @@ main(int argc, /* I - Number of command-line args */
14001400
if ((compatsize = write(fd, buffer, (size_t)bytes)) < 0)
14011401
{
14021402
perror("DEBUG: Unable to write temporary file");
1403+
if (tmpfilename[0])
1404+
unlink(tmpfilename);
14031405
return (CUPS_BACKEND_FAILED);
14041406
}
14051407

14061408
if ((bytes = backendRunLoop(-1, fd, snmp_fd, &(addrlist->addr), 0, 0,
14071409
backendNetworkSideCB)) < 0)
1410+
{
1411+
if (tmpfilename[0])
1412+
unlink(tmpfilename);
14081413
return (CUPS_BACKEND_FAILED);
1414+
}
14091415

14101416
compatsize += bytes;
14111417

backend/socket.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
313313

314314
sleep(5);
315315

316+
if (snmp_fd >= 0)
317+
_cupsSNMPClose(snmp_fd);
318+
if (print_fd != 0)
319+
close(print_fd);
316320
return (CUPS_BACKEND_FAILED);
317321
}
318322

@@ -324,6 +328,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
324328
{
325329
_cupsLangPrintFilter(stderr, "ERROR",
326330
_("The printer is not responding."));
331+
if (snmp_fd >= 0)
332+
_cupsSNMPClose(snmp_fd);
333+
if (print_fd != 0)
334+
close(print_fd);
327335
return (CUPS_BACKEND_FAILED);
328336
}
329337

@@ -429,8 +437,6 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
429437

430438
close(device_fd);
431439

432-
httpAddrFreeList(addrlist);
433-
434440
/*
435441
* Close the input file and return...
436442
*/

0 commit comments

Comments
 (0)