From: Bernhard Miklautz Date: Wed, 25 Mar 2015 16:37:46 +0000 (+0100) Subject: Integrate feedback from pull request (#2492) X-Git-Tag: 2.0.0-beta1+android10~613^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d7b3694a981a4ee1c310e9c45227c303ba44bbf;p=platform%2Fupstream%2Ffreerdp.git Integrate feedback from pull request (#2492) * shell: add missing NULL checks * thread: handle case where HAVE_EVENTFD_H isn't defined * wlog: return NULL instead of 0 * wlog: use g_RootLog instead of WLog_GetRoot otherwise a new root might be initialized on uninit * indentation and style fixes --- diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 5f646c5..ee11baf 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -811,6 +811,8 @@ char* GetNamedPipeUnixDomainSocketBaseFilePathA() char* lpTempPath; char* lpPipePath; lpTempPath = GetKnownPath(KNOWN_PATH_TEMP); + if (!lpTempPath) + return NULL; lpPipePath = GetCombinedPath(lpTempPath, ".pipe"); free(lpTempPath); return lpPipePath; diff --git a/winpr/libwinpr/io/device.c b/winpr/libwinpr/io/device.c index 15ef9d2..6e26cca 100644 --- a/winpr/libwinpr/io/device.c +++ b/winpr/libwinpr/io/device.c @@ -84,6 +84,8 @@ char* GetDeviceFileUnixDomainSocketBaseFilePathA() char* lpPipePath; lpTempPath = GetKnownPath(KNOWN_PATH_TEMP); + if (!lpTempPath) + return NULL; lpPipePath = GetCombinedPath(lpTempPath, ".device"); free(lpTempPath); diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index f586619..d825c44 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -115,8 +115,15 @@ char* GetPath_XDG_DATA_HOME() return path; home = GetPath_HOME(); + if (!home) + return NULL; path = (char*) malloc(strlen(home) + strlen("/.local/share") + 1); + if (!path) + { + free(home); + return NULL; + } sprintf(path, "%s%s", home, "/.local/share"); free(home); @@ -147,6 +154,9 @@ char* GetPath_XDG_CONFIG_HOME() if (!home) home = GetPath_TEMP(); + if (!home) + return NULL; + path = (char*) malloc(strlen(home) + strlen("/.config") + 1); if (!path) { diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 53d17d2..dc355bf 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -380,7 +380,10 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize if(pthread_mutex_init(&thread->mutex, 0) != 0) { WLog_ERR(TAG, "failed to initialize thread mutex"); - close(thread->pipe_fd[0]); + if (thread->pipe_fd[0]) + close(thread->pipe_fd[0]); + if (thread->pipe_fd[1]) + close(thread->pipe_fd[1]); free(thread); return NULL; } @@ -394,7 +397,10 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize if (!thread_list) { WLog_ERR(TAG, "Couldn't create global thread list"); - close(thread->pipe_fd[0]); + if (thread->pipe_fd[0]) + close(thread->pipe_fd[0]); + if (thread->pipe_fd[1]) + close(thread->pipe_fd[1]); free(thread); return NULL; } diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c index 16a57d5..e2f2b93 100644 --- a/winpr/libwinpr/utils/collections/PubSub.c +++ b/winpr/libwinpr/utils/collections/PubSub.c @@ -207,19 +207,18 @@ wPubSub* PubSub_New(BOOL synchronized) if (!pubSub) return NULL; - pubSub->synchronized = synchronized; + pubSub->synchronized = synchronized; - if (pubSub->synchronized) - if (!InitializeCriticalSectionAndSpinCount(&pubSub->lock, 4000)) - { - free(pubSub); - return NULL; - } + if (pubSub->synchronized && !InitializeCriticalSectionAndSpinCount(&pubSub->lock, 4000)) + { + free(pubSub); + return NULL; + } - pubSub->count = 0; - pubSub->size = 64; + pubSub->count = 0; + pubSub->size = 64; - pubSub->events = (wEventType*) calloc(1, sizeof(wEventType) * pubSub->size); + pubSub->events = (wEventType*) calloc(1, sizeof(wEventType) * pubSub->size); if (!pubSub->events) { if (pubSub->synchronized) diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index 5bd0db5..69ca213 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -525,7 +525,7 @@ wLog* WLog_New(LPCSTR name, wLog* rootLogger) log = (wLog*) calloc(1, sizeof(wLog)); if (!log) - return 0; + return NULL; log->Name = _strdup(name); @@ -730,7 +730,7 @@ void WLog_Uninit() { DWORD index; wLog* child = NULL; - wLog* root = WLog_GetRoot(); + wLog* root = g_RootLog; if (!root) return;