blob: 9d8f06f8c2fcecd0c2aad1e3eb2ac8e4855878f9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
$FreeBSD$
--- io.c.orig
+++ io.c
@@ -2480,9 +2480,12 @@
{
struct stat sbuf;
struct open_hook *oh;
+ int iop_malloced = FALSE;
- if (iop == NULL)
+ if (iop == NULL) {
emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
+ iop_malloced = TRUE;
+ }
memset(iop, '\0', sizeof(IOBUF));
iop->flag = 0;
iop->fd = fd;
@@ -2495,7 +2498,8 @@
}
if (iop->fd == INVALID_HANDLE) {
- free(iop);
+ if (iop_malloced)
+ free(iop);
return NULL;
}
if (isatty(iop->fd))
|