caller to crash. Fix leak and return an error instead. from Chad Loder
int ret = -1;
unsigned long l;
unsigned short port;
- char *p;
+ char *p, *tmp;
struct {
/*
p = *addr;
if (p) {
*p = '\0';
- p = realloc(p, nl);
+ if (!(tmp = realloc(p, nl))) {
+ ret = -1;
+ free(p);
+ *addr = NULL;
+ BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
+ goto end;
+ }
+ p = tmp;
} else {
p = malloc(nl);
}
if (p == NULL) {
+ ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
}
port = ntohs(sa.from.sa_in.sin_port);
if (*addr == NULL) {
if ((p = malloc(24)) == NULL) {
+ ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
}
int ret = -1;
unsigned long l;
unsigned short port;
- char *p;
+ char *p, *tmp;
struct {
/*
p = *addr;
if (p) {
*p = '\0';
- p = realloc(p, nl);
+ if (!(tmp = realloc(p, nl))) {
+ ret = -1;
+ free(p);
+ *addr = NULL;
+ BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
+ goto end;
+ }
+ p = tmp;
} else {
p = malloc(nl);
}
if (p == NULL) {
+ ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
}
port = ntohs(sa.from.sa_in.sin_port);
if (*addr == NULL) {
if ((p = malloc(24)) == NULL) {
+ ret = -1;
BIOerr(BIO_F_BIO_ACCEPT, ERR_R_MALLOC_FAILURE);
goto end;
}