未验证 提交 cfa7527c 编写于 作者: S slguan 提交者: GitHub

Merge pull request #305 from H-ZeX/fix-mem-leak

fix memory leak in os/linux/src/os.c::taosInitTimer #304 
......@@ -223,6 +223,7 @@ int taosOpenUDServerSocket(char *ip, short port) {
return sockFd;
}
// The callback functions MUST free the param pass to it after finishing use it.
int taosInitTimer(void *(*callback)(void *), int ms) {
/********************************************************
* Create SIGALRM loop thread
......@@ -237,9 +238,10 @@ int taosInitTimer(void *(*callback)(void *), int ms) {
return -1;
}
int *tms = (int *)malloc(sizeof(int));
int *tms = (int *) malloc(sizeof(int));
*tms = ms;
if (pthread_create(&thread, &tattr, callback, (void *)tms)) {
if (pthread_create(&thread, &tattr, callback, (void *) tms)) {
free(tms);
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册