X-Git-Url: https://git.tcpdump.org/libpcap/blobdiff_plain/f4c3cf29cbb291901258c2f05aba77adab40a686..9df01dba7d4a698dbfec57e678e5a73dae93fa6d:/optimize.c diff --git a/optimize.c b/optimize.c index 4afd063f..283a6de3 100644 --- a/optimize.c +++ b/optimize.c @@ -2069,7 +2069,7 @@ opt_error(opt_state_t *opt_state, const char *fmt, ...) if (opt_state->errbuf != NULL) { va_start(ap, fmt); - (void)pcap_vsnprintf(opt_state->errbuf, + (void)vsnprintf(opt_state->errbuf, PCAP_ERRBUF_SIZE, fmt, ap); va_end(ap); } @@ -2182,7 +2182,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic) opt_state->n_edges = 2 * opt_state->n_blocks; opt_state->edges = (struct edge **)calloc(opt_state->n_edges, sizeof(*opt_state->edges)); if (opt_state->edges == NULL) { - free(opt_state->blocks); opt_error(opt_state, "malloc"); } @@ -2191,8 +2190,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic) */ opt_state->levels = (struct block **)calloc(opt_state->n_blocks, sizeof(*opt_state->levels)); if (opt_state->levels == NULL) { - free(opt_state->edges); - free(opt_state->blocks); opt_error(opt_state, "malloc"); } @@ -2203,9 +2200,6 @@ opt_init(opt_state_t *opt_state, struct icode *ic) opt_state->space = (bpf_u_int32 *)malloc(2 * opt_state->n_blocks * opt_state->nodewords * sizeof(*opt_state->space) + opt_state->n_edges * opt_state->edgewords * sizeof(*opt_state->space)); if (opt_state->space == NULL) { - free(opt_state->levels); - free(opt_state->edges); - free(opt_state->blocks); opt_error(opt_state, "malloc"); } p = opt_state->space; @@ -2245,19 +2239,10 @@ opt_init(opt_state_t *opt_state, struct icode *ic) opt_state->maxval = 3 * max_stmts; opt_state->vmap = (struct vmapinfo *)calloc(opt_state->maxval, sizeof(*opt_state->vmap)); if (opt_state->vmap == NULL) { - free(opt_state->space); - free(opt_state->levels); - free(opt_state->edges); - free(opt_state->blocks); opt_error(opt_state, "malloc"); } opt_state->vnode_base = (struct valnode *)calloc(opt_state->maxval, sizeof(*opt_state->vnode_base)); if (opt_state->vnode_base == NULL) { - free(opt_state->vmap); - free(opt_state->space); - free(opt_state->levels); - free(opt_state->edges); - free(opt_state->blocks); opt_error(opt_state, "malloc"); } } @@ -2501,7 +2486,7 @@ icode_to_fcode(struct icode *ic, struct block *root, u_int *lenp, fp = (struct bpf_insn *)malloc(sizeof(*fp) * n); if (fp == NULL) { - (void)pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, + (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc"); free(fp); return NULL; @@ -2528,7 +2513,7 @@ conv_error(conv_state_t *conv_state, const char *fmt, ...) va_list ap; va_start(ap, fmt); - (void)pcap_vsnprintf(conv_state->errbuf, + (void)vsnprintf(conv_state->errbuf, PCAP_ERRBUF_SIZE, fmt, ap); va_end(ap); longjmp(conv_state->top_ctx, 1); @@ -2552,7 +2537,7 @@ install_bpf_program(pcap_t *p, struct bpf_program *fp) * Validate the program. */ if (!pcap_validate_filter(fp->bf_insns, fp->bf_len)) { - pcap_snprintf(p->errbuf, sizeof(p->errbuf), + snprintf(p->errbuf, sizeof(p->errbuf), "BPF program is not valid"); return (-1); }