mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Not using realloc2 in set_ports_option
This commit is contained in:
1 parent
5591aa5a0d
commit
c0eb3e56b4
1 file changed
+8
-8
+8
-8
@@ -4547,7 +4547,7 @@ static int set_ports_option(struct mg_context *ctx) {
|
|||||||
int off = 0;
|
int off = 0;
|
||||||
#endif
|
#endif
|
||||||
struct vec vec;
|
struct vec vec;
|
||||||
struct socket so;
|
struct socket so, *ptr;
|
||||||
|
|
||||||
while (success && (list = next_option(list, &vec, NULL)) != NULL) {
|
while (success && (list = next_option(list, &vec, NULL)) != NULL) {
|
||||||
if (!parse_port_string(&vec, &so)) {
|
if (!parse_port_string(&vec, &so)) {
|
||||||
@@ -4573,15 +4573,15 @@ static int set_ports_option(struct mg_context *ctx) {
|
|||||||
(int) vec.len, vec.ptr, strerror(ERRNO));
|
(int) vec.len, vec.ptr, strerror(ERRNO));
|
||||||
closesocket(so.sock);
|
closesocket(so.sock);
|
||||||
success = 0;
|
success = 0;
|
||||||
|
} else if ((ptr = realloc(ctx->listening_sockets,
|
||||||
|
(ctx->num_listening_sockets + 1) *
|
||||||
|
sizeof(ctx->listening_sockets[0]))) == NULL) {
|
||||||
|
success = 0;
|
||||||
} else {
|
} else {
|
||||||
set_close_on_exec(so.sock);
|
set_close_on_exec(so.sock);
|
||||||
ctx->listening_sockets = realloc2(ctx->listening_sockets,
|
ctx->listening_sockets = ptr;
|
||||||
(ctx->num_listening_sockets + 1) *
|
ctx->listening_sockets[ctx->num_listening_sockets] = so;
|
||||||
sizeof(ctx->listening_sockets[0]));
|
ctx->num_listening_sockets++;
|
||||||
if (ctx->listening_sockets != NULL) {
|
|
||||||
ctx->listening_sockets[ctx->num_listening_sockets] = so;
|
|
||||||
ctx->num_listening_sockets++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user