summaryrefslogtreecommitdiff
path: root/mysys/thr_alarm.c
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-07-16 16:17:17 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-07-23 14:33:22 +0400
commitd897015d74d82464a21ed154f606adc69503c372 (patch)
tree5ebf8366f96a0b8d5c8172c38629314018700142 /mysys/thr_alarm.c
parentcb3a71d238996ee6054fa6bb7cf47435d474dc55 (diff)
downloadmariadb-git-d897015d74d82464a21ed154f606adc69503c372.tar.gz
MDEV-8399 - [PATCH] Missing Sanity Checks for memory allocation in MariaDB
- since param is quite small store it on stack - fixed a few memory leaks
Diffstat (limited to 'mysys/thr_alarm.c')
-rw-r--r--mysys/thr_alarm.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c
index d0bb2f1ef4c..9d917d3dd59 100644
--- a/mysys/thr_alarm.c
+++ b/mysys/thr_alarm.c
@@ -694,7 +694,7 @@ static void *test_thread(void *arg)
thread_count--;
mysql_cond_signal(&COND_thread_count); /* Tell main we are ready */
mysql_mutex_unlock(&LOCK_thread_count);
- free((uchar*) arg);
+ my_thread_end();
return 0;
}
@@ -771,7 +771,7 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
{
pthread_t tid;
pthread_attr_t thr_attr;
- int i,*param,error;
+ int i, param[2], error;
sigset_t set;
ALARM_INFO alarm_info;
MY_INIT(argv[0]);
@@ -815,12 +815,11 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
printf("Main thread: %s\n",my_thread_name());
for (i=0 ; i < 2 ; i++)
{
- param=(int*) malloc(sizeof(int));
- *param= i;
+ param[i]= i;
mysql_mutex_lock(&LOCK_thread_count);
if ((error= mysql_thread_create(0,
&tid, &thr_attr, test_thread,
- (void*) param)))
+ (void*) &param[i])))
{
printf("Can't create thread %d, error: %d\n",i,error);
exit(1);
@@ -851,6 +850,9 @@ int main(int argc __attribute__((unused)),char **argv __attribute__((unused)))
alarm_info.active_alarms, alarm_info.max_used_alarms,
alarm_info.next_alarm_time);
printf("Test succeeded\n");
+ mysql_cond_destroy(&COND_thread_count);
+ mysql_mutex_destroy(&LOCK_thread_count);
+ my_end(MY_CHECK_ERROR);
return 0;
}