mirror of
https://github.com/hufrea/byedpi.git
synced 2024-11-24 15:55:31 +03:00
fix mem_destroy, clear_params
This commit is contained in:
parent
d4e3ac5a85
commit
b0277dba6b
2 changed files with 8 additions and 5 deletions
9
main.c
9
main.c
|
@ -309,9 +309,10 @@ void clear_params(void)
|
|||
if (params.spos) {
|
||||
for (int i = 0; i < params.spos_n; i++) {
|
||||
struct spos s = params.spos[i];
|
||||
if (!s.data) continue;
|
||||
free(s.data);
|
||||
s.data = 0;
|
||||
if (s.data != 0) {
|
||||
free(s.data);
|
||||
s.data = 0;;
|
||||
}
|
||||
}
|
||||
free(params.spos);
|
||||
params.spos = 0;
|
||||
|
@ -323,7 +324,7 @@ void clear_params(void)
|
|||
free(s.ip_options);
|
||||
s.ip_options = ip_option;
|
||||
}
|
||||
if (!s.parts) {
|
||||
if (s.parts != 0) {
|
||||
free(s.parts);
|
||||
s.parts = 0;
|
||||
}
|
||||
|
|
4
mpool.c
4
mpool.c
|
@ -117,7 +117,7 @@ void mem_delete(struct mphdr *hdr, int pos)
|
|||
|
||||
void mem_destroy(struct mphdr *hdr)
|
||||
{
|
||||
for (int i = 0; i < hdr->count; i++) {
|
||||
for (int i = 0; i < hdr->count && hdr->values; i++) {
|
||||
struct elem *e = hdr->values[i];
|
||||
if (!e) {
|
||||
continue;
|
||||
|
@ -125,4 +125,6 @@ void mem_destroy(struct mphdr *hdr)
|
|||
free(e);
|
||||
hdr->values[i] = 0;
|
||||
}
|
||||
memset(hdr, 0, sizeof(*hdr));
|
||||
free(hdr);
|
||||
}
|
Loading…
Reference in a new issue