From 818b4219f6b411e0a5bc93250a729a0490589931 Mon Sep 17 00:00:00 2001 From: David Robson Date: Tue, 25 Apr 2017 14:02:31 -0700 Subject: [PATCH] Avoid calling VECTOR_size(NULL). --- .../outprocess_loader_ut/outprocess_loader_ut.c | 4 +--- .../src/module_loaders/outprocess_loader.c | 12 ++++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/core/tests/outprocess_loader_ut/outprocess_loader_ut.c b/core/tests/outprocess_loader_ut/outprocess_loader_ut.c index 654f6621..97b60134 100644 --- a/core/tests/outprocess_loader_ut/outprocess_loader_ut.c +++ b/core/tests/outprocess_loader_ut/outprocess_loader_ut.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include @@ -1404,8 +1404,6 @@ TEST_FUNCTION(OutprocessLoader_JoinChildProcesses_SCENARIO_no_threads_running) // Expected call listing umock_c_reset_all_calls(); - STRICT_EXPECTED_CALL(VECTOR_size(NULL)) - .SetReturn(0); EXPECTED_CALL(uv_default_loop()) .SetReturn(MOCK_UV_LOOP); STRICT_EXPECTED_CALL(uv_loop_alive(MOCK_UV_LOOP)) diff --git a/proxy/outprocess/src/module_loaders/outprocess_loader.c b/proxy/outprocess/src/module_loaders/outprocess_loader.c index edbba0c8..5f689156 100644 --- a/proxy/outprocess/src/module_loaders/outprocess_loader.c +++ b/proxy/outprocess/src/module_loaders/outprocess_loader.c @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All rights reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include "module_loaders/outprocess_loader.h" @@ -249,7 +249,7 @@ int OutprocessLoader_SpawnChildProcesses(void) { void OutprocessLoader_JoinChildProcesses(void) { /* Codes_SRS_OUTPROCESS_LOADER_27_064: [ `OutprocessLoader_JoinChildProcesses` shall get the count of child processes, by calling `size_t VECTOR_size(VECTOR_HANDLE handle)`. ] */ - const size_t child_count = VECTOR_size(uv_processes); + const size_t child_count = (uv_processes == NULL)? 0 :VECTOR_size(uv_processes); TICK_COUNTER_HANDLE ticks = NULL; tickcounter_ms_t started_waiting; @@ -313,12 +313,8 @@ void OutprocessLoader_JoinChildProcesses(void) { uv_process_grace_period_ms = 0; - if (NULL == uv_thread) - { - /* Codes_SRS_OUTPROCESS_LOADER_27_050: [ Prerequisite Check - If no threads are running, then `OutprocessLoader_JoinChildProcesses` shall abandon the effort to join the child processes immediately. ] */ - LogInfo("The process management thread is not currently running."); - } - else + /* Codes_SRS_OUTPROCESS_LOADER_27_050: [ Prerequisite Check - If no threads are running, then `OutprocessLoader_JoinChildProcesses` shall abandon the effort to join the child processes immediately. ] */ + if (NULL != uv_thread) { /* Codes_SRS_OUTPROCESS_LOADER_27_062: [ `OutprocessLoader_JoinChildProcesses` shall join the child process management thread, by calling `THREADAPI_RESULT ThreadAPI_Join(THREAD_HANDLE threadHandle, int * res)`. ] */ (void)ThreadAPI_Join(uv_thread, &uv_thread_result);