Stop retaining pointers to stack variables
This commit is contained in:
parent
f2d1ccd779
commit
7945e25fef
1 changed files with 3 additions and 5 deletions
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct LogFrame {
|
||||
struct LogFrame *next;
|
||||
struct IP *ip;
|
||||
struct IP ip;
|
||||
Port port;
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ void append_frame(struct LogFrame **log, struct IP *ip, Port port) {
|
|||
struct LogFrame *new_log_frame = (struct LogFrame*) malloc(sizeof(struct LogFrame));
|
||||
memset(new_log_frame, 0, sizeof(struct LogFrame));
|
||||
|
||||
new_log_frame->ip = ip;
|
||||
new_log_frame->ip = *ip;
|
||||
new_log_frame->port = port;
|
||||
|
||||
if (*log == NULL) {
|
||||
|
@ -72,8 +72,6 @@ void add_frame(struct Rule* rule) {
|
|||
}
|
||||
|
||||
int check_ip_and_port(struct IP *ip, Port port) {
|
||||
// TODO: ip=255.255.255.255??
|
||||
|
||||
pthread_rwlock_wrlock(&persist_lock);
|
||||
|
||||
struct Frame *cursor = persist_head;
|
||||
|
@ -182,7 +180,7 @@ int list_rules(int sd) {
|
|||
if (send(sd, "Query: ", 7, 0) == -1) {
|
||||
return -1;
|
||||
}
|
||||
if (send_ip(sd, log_cursor->ip) == -1) {
|
||||
if (send_ip(sd, &log_cursor->ip) == -1) {
|
||||
status = -1;
|
||||
goto end;
|
||||
}
|
||||
|
|
Reference in a new issue