1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

mem_free_if where aplicable. Initialised memory in encoding/*

This commit is contained in:
Witold Filipczyk 2015-05-10 17:27:55 +02:00
parent ca4d770c0b
commit c84dfd7e18
9 changed files with 11 additions and 9 deletions

View File

@ -90,7 +90,7 @@ new_menu_item(struct list_menu *menu, unsigned char *name, int data, int fullnam
}
if (!stack || !new_menu_item) {
if (new_menu_item) mem_free(new_menu_item);
mem_free_if(new_menu_item);
mem_free(name);
return;
}

View File

@ -195,7 +195,7 @@ html_input_format(struct html_context *html_context, unsigned char *a,
html_stack_dup(html_context, ELEMENT_KILLABLE);
html_focusable(html_context, a);
format.form = fc;
if (format.title) mem_free(format.title);
mem_free_if(format.title);
format.title = get_attr_val(a, "title", html_context->doc_cp);
switch (fc->type) {
case FC_TEXT:

View File

@ -98,7 +98,7 @@ kill_html_stack_item(struct html_context *html_context, struct html_element *e)
add_to_string_list(&html_context->part->document->onload_snippets,
onload, -1);
}
if (onload) mem_free(onload);
mem_free_if(onload);
#endif
mem_free_if(e->attr.link);

View File

@ -899,7 +899,7 @@ draw_table_cell(struct table *table, int col, int row, int x, int y,
done_html_parser_state(html_context, state);
if (part) mem_free(part);
mem_free_if(part);
}
static void

View File

@ -67,6 +67,7 @@ bzip2_open(struct stream_encoded *stream, int fd)
copy_struct(&data->fbz_stream, &null_bz_stream);
data->fdread = fd;
data->last_read = 0;
data->after_end = 0;
err = BZ2_bzDecompressInit(&data->fbz_stream, 0, 0);
if (err != BZ_OK) {
@ -189,7 +190,7 @@ bzip2_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int
*new_len = stream->total_out_lo32;
return buffer;
} else {
if (buffer) mem_free(buffer);
mem_free_if(buffer);
return NULL;
}
}

View File

@ -214,7 +214,7 @@ deflate_decode_buffer(struct stream_encoded *st, int window_size, unsigned char
*new_len = stream->total_out;
return buffer;
} else {
if (buffer) mem_free(buffer);
mem_free_if(buffer);
return NULL;
}
}

View File

@ -46,6 +46,7 @@ lzma_open(struct stream_encoded *stream, int fd)
memset(&data->flzma_stream, 0, sizeof(data->flzma_stream));
data->fdread = fd;
data->last_read = 0;
data->after_end = 0;
err = lzma_auto_decoder(&data->flzma_stream, ELINKS_LZMA_MEMORY_LIMIT, 0);
if (err != LZMA_OK) {
@ -153,7 +154,7 @@ lzma_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int
*new_len = stream->total_out;
return buffer;
} else {
if (buffer) mem_free(buffer);
mem_free_if(buffer);
return NULL;
}
}

View File

@ -281,7 +281,7 @@ add_bittorrent_selection(struct uri *uri, int *selection, size_t size)
int *duplicate;
duplicate = get_bittorrent_selection(uri, size);
if (duplicate) mem_free(duplicate);
mem_free_if(duplicate);
info = mem_calloc(1, sizeof(*info));
if (!info) return;

View File

@ -37,7 +37,7 @@ smjs_action_fn_finalize(JSContext *ctx, JSObject *obj)
hop = JS_GetInstancePrivate(ctx, obj,
(JSClass *) &action_fn_class, NULL);
if (hop) mem_free(hop);
mem_free_if(hop);
}
/* @action_fn_class.call */