More error_data memory leaks

This commit is contained in:
Bodo Möller 2001-03-15 11:30:10 +00:00
parent bb6dcb54f9
commit 5d8094143e
2 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,8 @@
Changes between 0.9.6 and 0.9.7 [xx XXX 2000] Changes between 0.9.6 and 0.9.7 [xx XXX 2000]
*) Fix a memory leak in err.c: free err_data string if necessary. *) Fix memory leaks in err.c: free err_data string if necessary;
don't write to the wrong index in ERR_set_error_data.
[Bodo Moeller] [Bodo Moeller]
*) Function EC_POINTs_mul for simultaneous scalar multiplication *) Function EC_POINTs_mul for simultaneous scalar multiplication

View File

@ -391,20 +391,18 @@ void ERR_put_error(int lib, int func, int reason, const char *file,
void ERR_clear_error(void) void ERR_clear_error(void)
{ {
int i;
ERR_STATE *es; ERR_STATE *es;
es=ERR_get_state(); es=ERR_get_state();
#if 0
/* hmm... is this needed */
for (i=0; i<ERR_NUM_ERRORS; i++) for (i=0; i<ERR_NUM_ERRORS; i++)
{ {
es->err_buffer[i]=0; es->err_buffer[i]=0;
err_clear_data(es,i);
es->err_file[i]=NULL; es->err_file[i]=NULL;
es->err_line[i]= -1; es->err_line[i]= -1;
err_clear_data(es,i);
} }
#endif
es->top=es->bottom=0; es->top=es->bottom=0;
} }
@ -764,8 +762,9 @@ void ERR_set_error_data(char *data, int flags)
if (i == 0) if (i == 0)
i=ERR_NUM_ERRORS-1; i=ERR_NUM_ERRORS-1;
err_clear_data(es,i);
es->err_data[i]=data; es->err_data[i]=data;
es->err_data_flags[es->top]=flags; es->err_data_flags[i]=flags;
} }
void ERR_add_error_data(int num, ...) void ERR_add_error_data(int num, ...)
@ -774,7 +773,7 @@ void ERR_add_error_data(int num, ...)
int i,n,s; int i,n,s;
char *str,*p,*a; char *str,*p,*a;
s=64; s=80;
str=OPENSSL_malloc(s+1); str=OPENSSL_malloc(s+1);
if (str == NULL) return; if (str == NULL) return;
str[0]='\0'; str[0]='\0';