mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
fixed memory leaks
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5167 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
ad5ca59a7a
commit
ba56f5f611
7 changed files with 33 additions and 43 deletions
|
@ -1124,11 +1124,9 @@ ops_write_literal_data_from_file(const char *filename,
|
|||
unsigned char buf[1024];
|
||||
ops_memory_t* mem=NULL;
|
||||
size_t len=0;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
return ops_false;
|
||||
|
||||
|
@ -1180,11 +1178,9 @@ ops_memory_t* ops_write_mem_from_file(const char *filename, int* errnum)
|
|||
ops_memory_t* mem=NULL;
|
||||
|
||||
*errnum=0;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
*errnum=errno;
|
||||
|
@ -1234,9 +1230,8 @@ int ops_write_file_from_buf(const char *filename, const char* buf,
|
|||
flags |= O_TRUNC;
|
||||
else
|
||||
flags |= O_EXCL;
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd=open(filename,flags, 0600);
|
||||
if (fd < 0)
|
||||
|
|
|
@ -691,11 +691,9 @@ ops_boolean_t ops_keyring_read_from_file(ops_keyring_t *keyring, const ops_boole
|
|||
|
||||
// ops_parse_options(pinfo,OPS_PTAG_SS_ALL,OPS_PARSE_RAW);
|
||||
ops_parse_options(pinfo,OPS_PTAG_SS_ALL,OPS_PARSE_PARSED);
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY);
|
||||
#endif
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
ops_parse_info_delete(pinfo);
|
||||
|
|
|
@ -139,9 +139,7 @@ int ops_setup_file_write(ops_create_info_t **cinfo, const char* filename, ops_bo
|
|||
flags |= O_TRUNC;
|
||||
else
|
||||
flags |= O_EXCL;
|
||||
#ifdef WINDOWS_SYS
|
||||
flags |= O_BINARY;
|
||||
#endif
|
||||
|
||||
fd=open(filename, flags, 0600);
|
||||
if(fd < 0)
|
||||
|
@ -181,11 +179,8 @@ int ops_setup_file_append(ops_create_info_t **cinfo, const char* filename)
|
|||
* initialise needed structures for writing to file
|
||||
*/
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
fd=open(filename,O_WRONLY | O_APPEND | O_BINARY, 0600);
|
||||
#else
|
||||
fd=open(filename,O_WRONLY | O_APPEND , 0600);
|
||||
#endif
|
||||
|
||||
if(fd < 0)
|
||||
{
|
||||
perror(filename);
|
||||
|
@ -230,11 +225,8 @@ int ops_setup_file_read(ops_parse_info_t **pinfo, const char *filename,
|
|||
* initialise needed structures for reading
|
||||
*/
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
fd=open(filename,O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd=open(filename,O_RDONLY );
|
||||
#endif
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror(filename);
|
||||
|
|
|
@ -958,11 +958,9 @@ ops_boolean_t ops_sign_file_as_cleartext(const char* input_filename,
|
|||
ops_boolean_t use_armour=ops_true;
|
||||
|
||||
// open file to sign
|
||||
#ifdef WINDOWS_SYS
|
||||
|
||||
fd_in=open(input_filename, O_RDONLY | O_BINARY);
|
||||
#else
|
||||
fd_in=open(input_filename, O_RDONLY );
|
||||
#endif
|
||||
|
||||
if(fd_in < 0)
|
||||
{
|
||||
return ops_false;
|
||||
|
|
|
@ -116,9 +116,11 @@ static int keydata_reader(void *dest,size_t length,ops_error_t **errors,
|
|||
return length;
|
||||
}
|
||||
|
||||
static void free_signature_info(ops_signature_info_t *sig)
|
||||
static void free_signature_info(ops_signature_info_t *sig,int n)
|
||||
{
|
||||
free (sig->v4_hashed_data);
|
||||
int i ;
|
||||
for(i=0;i<n;++i)
|
||||
free (sig[i].v4_hashed_data);
|
||||
free (sig);
|
||||
}
|
||||
|
||||
|
@ -145,7 +147,6 @@ static void add_sig_to_valid_list(ops_validate_result_t * result, const ops_sign
|
|||
result->valid_sigs=realloc(result->valid_sigs, newsize);
|
||||
|
||||
// copy key ptr to array
|
||||
start=(sizeof *sig) * (result->valid_count-1);
|
||||
copy_signature_info(&result->valid_sigs[result->valid_count-1],sig);
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,6 @@ static void add_sig_to_invalid_list(ops_validate_result_t * result, const ops_si
|
|||
result->invalid_sigs=realloc(result->invalid_sigs, newsize);
|
||||
|
||||
// copy key ptr to array
|
||||
start=(sizeof *sig) * (result->invalid_count-1);
|
||||
copy_signature_info(&result->invalid_sigs[result->invalid_count-1],sig);
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,6 @@ static void add_sig_to_unknown_list(ops_validate_result_t * result, const ops_si
|
|||
result->unknown_sigs=realloc(result->unknown_sigs, newsize);
|
||||
|
||||
// copy key id to array
|
||||
start=OPS_KEY_ID_SIZE * (result->unknown_signer_count-1);
|
||||
copy_signature_info(&result->unknown_sigs[result->unknown_signer_count-1],sig);
|
||||
}
|
||||
|
||||
|
@ -607,11 +606,11 @@ void ops_validate_result_free(ops_validate_result_t *result)
|
|||
return;
|
||||
|
||||
if (result->valid_sigs)
|
||||
free_signature_info(result->valid_sigs);
|
||||
free_signature_info(result->valid_sigs,result->valid_count);
|
||||
if (result->invalid_sigs)
|
||||
free_signature_info(result->invalid_sigs);
|
||||
free_signature_info(result->invalid_sigs,result->invalid_count);
|
||||
if (result->unknown_sigs)
|
||||
free_signature_info(result->unknown_sigs);
|
||||
free_signature_info(result->unknown_sigs,result->unknown_signer_count);
|
||||
|
||||
free(result);
|
||||
result=NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue