mirror of
https://github.com/bol-van/zapret.git
synced 2025-01-12 19:20:35 +05:00
nfqws,tpws: remove null pointer checks before free()
This commit is contained in:
parent
f21bd0c63c
commit
29ff997a3f
@ -26,13 +26,10 @@ static void connswap(const t_conn *c, t_conn *c2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConntrackClearHostname(t_ctrack *track)
|
void ConntrackClearHostname(t_ctrack *track)
|
||||||
{
|
|
||||||
if (track->hostname)
|
|
||||||
{
|
{
|
||||||
free(track->hostname);
|
free(track->hostname);
|
||||||
track->hostname = NULL;
|
track->hostname = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
static void ConntrackClearTrack(t_ctrack *track)
|
static void ConntrackClearTrack(t_ctrack *track)
|
||||||
{
|
{
|
||||||
ConntrackClearHostname(track);
|
ConntrackClearHostname(track);
|
||||||
@ -348,12 +345,9 @@ void ConntrackPoolDump(const t_conntrack *p)
|
|||||||
|
|
||||||
|
|
||||||
void ReasmClear(t_reassemble *reasm)
|
void ReasmClear(t_reassemble *reasm)
|
||||||
{
|
|
||||||
if (reasm->packet)
|
|
||||||
{
|
{
|
||||||
free(reasm->packet);
|
free(reasm->packet);
|
||||||
reasm->packet = NULL;
|
reasm->packet = NULL;
|
||||||
}
|
|
||||||
reasm->size = reasm->size_present = 0;
|
reasm->size = reasm->size_present = 0;
|
||||||
}
|
}
|
||||||
bool ReasmInit(t_reassemble *reasm, size_t size_requested, uint32_t seq_start)
|
bool ReasmInit(t_reassemble *reasm, size_t size_requested, uint32_t seq_start)
|
||||||
|
@ -65,11 +65,8 @@ int z_readfile(FILE *F, char **buf, size_t *size)
|
|||||||
|
|
||||||
zerr:
|
zerr:
|
||||||
inflateEnd(&zs);
|
inflateEnd(&zs);
|
||||||
if (*buf)
|
|
||||||
{
|
|
||||||
free(*buf);
|
free(*buf);
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
}
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ bool strlist_add(struct str_list_head *head, const char *filename)
|
|||||||
}
|
}
|
||||||
static void strlist_entry_destroy(struct str_list *entry)
|
static void strlist_entry_destroy(struct str_list *entry)
|
||||||
{
|
{
|
||||||
if (entry->str) free(entry->str);
|
free(entry->str);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
void strlist_destroy(struct str_list_head *head)
|
void strlist_destroy(struct str_list_head *head)
|
||||||
@ -178,7 +178,7 @@ struct hostlist_file *hostlist_files_add(struct hostlist_files_head *head, const
|
|||||||
}
|
}
|
||||||
static void hostlist_files_entry_destroy(struct hostlist_file *entry)
|
static void hostlist_files_entry_destroy(struct hostlist_file *entry)
|
||||||
{
|
{
|
||||||
if (entry->filename) free(entry->filename);
|
free(entry->filename);
|
||||||
StrPoolDestroy(&entry->hostlist);
|
StrPoolDestroy(&entry->hostlist);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ struct ipset_file *ipset_files_add(struct ipset_files_head *head, const char *fi
|
|||||||
}
|
}
|
||||||
static void ipset_files_entry_destroy(struct ipset_file *entry)
|
static void ipset_files_entry_destroy(struct ipset_file *entry)
|
||||||
{
|
{
|
||||||
if (entry->filename) free(entry->filename);
|
free(entry->filename);
|
||||||
ipsetDestroy(&entry->ipset);
|
ipsetDestroy(&entry->ipset);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,8 @@ int z_readfile(FILE *F, char **buf, size_t *size)
|
|||||||
|
|
||||||
zerr:
|
zerr:
|
||||||
inflateEnd(&zs);
|
inflateEnd(&zs);
|
||||||
if (*buf)
|
|
||||||
{
|
|
||||||
free(*buf);
|
free(*buf);
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
}
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ bool strlist_add(struct str_list_head *head, const char *filename)
|
|||||||
}
|
}
|
||||||
static void strlist_entry_destroy(struct str_list *entry)
|
static void strlist_entry_destroy(struct str_list *entry)
|
||||||
{
|
{
|
||||||
if (entry->str) free(entry->str);
|
free(entry->str);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
void strlist_destroy(struct str_list_head *head)
|
void strlist_destroy(struct str_list_head *head)
|
||||||
@ -177,7 +177,7 @@ struct hostlist_file *hostlist_files_add(struct hostlist_files_head *head, const
|
|||||||
}
|
}
|
||||||
static void hostlist_files_entry_destroy(struct hostlist_file *entry)
|
static void hostlist_files_entry_destroy(struct hostlist_file *entry)
|
||||||
{
|
{
|
||||||
if (entry->filename) free(entry->filename);
|
free(entry->filename);
|
||||||
StrPoolDestroy(&entry->hostlist);
|
StrPoolDestroy(&entry->hostlist);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ struct ipset_file *ipset_files_add(struct ipset_files_head *head, const char *fi
|
|||||||
}
|
}
|
||||||
static void ipset_files_entry_destroy(struct ipset_file *entry)
|
static void ipset_files_entry_destroy(struct ipset_file *entry)
|
||||||
{
|
{
|
||||||
if (entry->filename) free(entry->filename);
|
free(entry->filename);
|
||||||
ipsetDestroy(&entry->ipset);
|
ipsetDestroy(&entry->ipset);
|
||||||
free(entry);
|
free(entry);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "params.h"
|
#include "params.h"
|
||||||
|
#include "linux_compat.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -168,13 +168,10 @@ static bool send_buffer_realloc(send_buffer_t *sb, size_t extra_bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void send_buffer_free(send_buffer_t *sb)
|
static void send_buffer_free(send_buffer_t *sb)
|
||||||
{
|
|
||||||
if (sb->data)
|
|
||||||
{
|
{
|
||||||
free(sb->data);
|
free(sb->data);
|
||||||
sb->data = NULL;
|
sb->data = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
static void send_buffers_free(send_buffer_t *sb_array, int count)
|
static void send_buffers_free(send_buffer_t *sb_array, int count)
|
||||||
{
|
{
|
||||||
for (int i=0;i<count;i++)
|
for (int i=0;i<count;i++)
|
||||||
@ -520,7 +517,7 @@ static void free_conn(tproxy_conn_t *conn)
|
|||||||
}
|
}
|
||||||
conn_free_buffers(conn);
|
conn_free_buffers(conn);
|
||||||
if (conn->partner) conn->partner->partner=NULL;
|
if (conn->partner) conn->partner->partner=NULL;
|
||||||
if (conn->track.hostname) free(conn->track.hostname);
|
free(conn->track.hostname);
|
||||||
if (conn->socks_ri) conn->socks_ri->ptr = NULL; // detach conn
|
if (conn->socks_ri) conn->socks_ri->ptr = NULL; // detach conn
|
||||||
free(conn);
|
free(conn);
|
||||||
}
|
}
|
||||||
@ -1762,7 +1759,7 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct)
|
|||||||
|
|
||||||
ex:
|
ex:
|
||||||
if (efd) close(efd);
|
if (efd) close(efd);
|
||||||
if (listen_conn) free(listen_conn);
|
free(listen_conn);
|
||||||
resolver_deinit();
|
resolver_deinit();
|
||||||
if (resolve_pipe[0]) close(resolve_pipe[0]);
|
if (resolve_pipe[0]) close(resolve_pipe[0]);
|
||||||
if (resolve_pipe[1]) close(resolve_pipe[1]);
|
if (resolve_pipe[1]) close(resolve_pipe[1]);
|
||||||
|
Loading…
Reference in New Issue
Block a user