Skip to content

Commit a1bc861

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

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ 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);
320+
316321
return (CUPS_BACKEND_FAILED);
317322
}
318323

@@ -324,6 +329,10 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
324329
{
325330
_cupsLangPrintFilter(stderr, "ERROR",
326331
_("The printer is not responding."));
332+
if (snmp_fd >= 0)
333+
_cupsSNMPClose(snmp_fd);
334+
if (print_fd != 0)
335+
close(print_fd);
327336
return (CUPS_BACKEND_FAILED);
328337
}
329338

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

430439
close(device_fd);
431440

432-
httpAddrFreeList(addrlist);
433-
434441
/*
435442
* Close the input file and return...
436443
*/

0 commit comments

Comments
 (0)