Commit c0eb3e56 authored by Sergey Lyubka's avatar Sergey Lyubka

Not using realloc2 in set_ports_option

parent 5591aa5a
...@@ -4547,7 +4547,7 @@ static int set_ports_option(struct mg_context *ctx) { ...@@ -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) { ...@@ -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++;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment