Try to fix invalid free()

This commit is contained in:
Quentin Dufour 2019-04-04 10:19:55 +02:00
parent d6118a214d
commit 0d62fca3d4
2 changed files with 8 additions and 2 deletions

View file

@ -180,7 +180,9 @@ int on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
// 1. If has a "used" buffer, remove it
bp = g_hash_table_lookup (app_ctx->used_buffer, &(fdinfo->fd));
if (bp != NULL) {
fprintf(stderr, "begin removing entry in app_ctx->used_buffer for %s\n", fdinfo->url);
g_hash_table_remove (app_ctx->used_buffer, &(fdinfo->fd));
fprintf(stderr, "end removing entry in app_ctx->used_buffer\n");
memset(bp, 0, sizeof(struct buffer_packet));
g_queue_push_tail(app_ctx->free_buffer, bp);
}
@ -191,7 +193,11 @@ int on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
memset(bp, 0, sizeof(struct buffer_packet));
g_queue_push_tail(app_ctx->free_buffer, bp);
}
g_hash_table_remove (app_ctx->write_waiting, &(fdinfo->fd));
if (writew) {
fprintf(stderr, "begin removing entry in app_ctx->write_waiting for %s\n", fdinfo->url);
g_hash_table_remove (app_ctx->write_waiting, &(fdinfo->fd));
fprintf(stderr, "end removing entry in app_ctx->write_waiting for %s\n", fdinfo->url);
}
// 3. If appears in the read waiting queue, remove it
g_queue_remove_all (app_ctx->read_waiting, &(fdinfo->fd));

View file

@ -477,7 +477,7 @@ int rr_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
memset(bp, 0, sizeof(struct buffer_packet));
g_queue_push_tail(app_ctx->free_buffer, bp);
}
g_hash_table_remove (app_ctx->write_waiting, &(fdinfo->fd));
if (writew) g_hash_table_remove (app_ctx->write_waiting, &(fdinfo->fd));
// 3. If appears in the read waiting queue, remove it
g_queue_remove_all (app_ctx->read_waiting, &(fdinfo->fd));