segfault fix

master
Sergey Dorofeev 13 years ago
parent 096f382eaa
commit fde43cf87c

@ -78,21 +78,27 @@ void binkp_init(s_handshake_protocol *THIS)
void binkp_deinit(s_handshake_protocol *THIS) void binkp_deinit(s_handshake_protocol *THIS)
{ {
ASSERT(THIS); log("binkp_deinit");
ASSERT(THIS->remote_data); if (THIS==NULL) {
ASSERT(THIS->local_data); log("THIS==NULL");
return;
}
if( THIS->remote_data ) if( THIS->remote_data )
{ {
memset(THIS->remote_data, '\0', sizeof(s_binkp_sysinfo)); memset(THIS->remote_data, '\0', sizeof(s_binkp_sysinfo));
free(THIS->remote_data); free(THIS->remote_data);
THIS->remote_data = NULL;
} }
if( THIS->local_data ) if( THIS->local_data )
{ {
memset(THIS->local_data, '\0', sizeof(s_binkp_sysinfo)); memset(THIS->local_data, '\0', sizeof(s_binkp_sysinfo));
free(THIS->local_data); free(THIS->local_data);
THIS->local_data = NULL;
} }
log("binkp_deinit end");
} }
int binkp_incoming2(s_handshake_protocol *THIS) int binkp_incoming2(s_handshake_protocol *THIS)

@ -349,7 +349,7 @@ get_next_file:
if( !ptrl ) { if( !ptrl ) {
/* send file received through netspool */ /* send file received through netspool */
pi->send->fp = 0; pi->send->fp = 0;
pi->send->local_name = "NETSPOOL"; pi->send->local_name = (char*)xstrcpy("NETSPOOL");
pi->send->type = out_filetype(state.netspool.filename); pi->send->type = out_filetype(state.netspool.filename);
pi->send->net_name = recode_file_out(p_convfilename(state.netspool.filename, pi->send->type)); pi->send->net_name = recode_file_out(p_convfilename(state.netspool.filename, pi->send->type));
pi->send->fname = NULL; pi->send->fname = NULL;
@ -749,7 +749,9 @@ static int p_move2inbound(s_protinfo *pi)
{ {
log("recv: cannot get unique name for \"%s\"", log("recv: cannot get unique name for \"%s\"",
pi->recv->local_name); pi->recv->local_name);
log("free realname");
free(realname); free(realname);
log("freed");
return 1; return 1;
} }
@ -796,10 +798,16 @@ static int p_move2inbound(s_protinfo *pi)
destname); destname);
} }
if( realname ) if( realname ) {
log("free realname");
free(realname); free(realname);
if( uniqname ) log("freed");
}
if( uniqname ) {
log("free uniqname");
free(uniqname); free(uniqname);
log("freed");
}
return rc ? 1 : 0; return rc ? 1 : 0;
} }
@ -984,8 +992,9 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
pi->recv->status = FSTAT_SKIPPED; pi->recv->status = FSTAT_SKIPPED;
} }
} }
log("free fname");
free(fname); fname = NULL; free(fname); fname = NULL;
log("freed");
if( pi->recv->status == FSTAT_SKIPPED ) if( pi->recv->status == FSTAT_SKIPPED )
return 2; return 2;
@ -1013,8 +1022,10 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
else else
pi->recv->status = FSTAT_REFUSED; pi->recv->status = FSTAT_REFUSED;
log("free pi->recv->fname");
free(pi->recv->fname); free(pi->recv->fname);
pi->recv->fname = NULL; pi->recv->fname = NULL;
log("freed");
return pi->recv->status == FSTAT_SKIPPED ? 2 : 1; return pi->recv->status == FSTAT_SKIPPED ? 2 : 1;
} }
@ -1636,6 +1647,7 @@ char *prot_unique_name(char *dirname, char *fname, int type)
*/ */
void deinit_finfo(s_finfo *fi) void deinit_finfo(s_finfo *fi)
{ {
log("deinit_finfo");
if( fi->fp ) if( fi->fp )
fclose(fi->fp); fclose(fi->fp);
@ -1647,6 +1659,7 @@ void deinit_finfo(s_finfo *fi)
free(fi->fname); free(fi->fname);
memset(fi, '\0', sizeof(s_finfo)); memset(fi, '\0', sizeof(s_finfo));
log("deinit_finfo end");
} }
/***************************************************************************** /*****************************************************************************
@ -1764,6 +1777,7 @@ void init_protinfo(s_protinfo *pi, bool caller)
void deinit_protinfo(s_protinfo *pi) void deinit_protinfo(s_protinfo *pi)
{ {
int i; int i;
log("deinit_protinfo");
for( i = 0; i < pi->n_sentfiles; i++ ) for( i = 0; i < pi->n_sentfiles; i++ )
deinit_finfo(&pi->sentfiles[i]); deinit_finfo(&pi->sentfiles[i]);
@ -1779,4 +1793,5 @@ void deinit_protinfo(s_protinfo *pi)
free(pi->rcvdfiles); free(pi->rcvdfiles);
memset(pi, '\0', sizeof(s_protinfo)); memset(pi, '\0', sizeof(s_protinfo));
log("deinit_protinfo end");
} }

@ -719,8 +719,11 @@ exit:
if (pi->send) p_tx_fclose(pi); if (pi->send) p_tx_fclose(pi);
if( txbuf ) if( txbuf ) {
free(txbuf); free(txbuf);
txbuf = NULL;
}
return(rc); return(rc);
} }

@ -164,6 +164,7 @@ void init_state(s_state *pstate)
void deinit_state(s_state *pstate) void deinit_state(s_state *pstate)
{ {
log("deinit_state begin");
if (pstate->linename) free(pstate->linename); if (pstate->linename) free(pstate->linename);
if (pstate->cidstr) free(pstate->cidstr); if (pstate->cidstr) free(pstate->cidstr);
if (pstate->peername) free(pstate->peername); if (pstate->peername) free(pstate->peername);
@ -184,6 +185,7 @@ void deinit_state(s_state *pstate)
memset(pstate, '\0', sizeof(s_state)); memset(pstate, '\0', sizeof(s_state));
pstate->session_rc = -1; pstate->session_rc = -1;
log("deinit_state end");
} }
s_faddr *session_1remote_address() s_faddr *session_1remote_address()

Loading…
Cancel
Save