From 50dc355da6dfd81ad9576730436505a740f56ef9 Mon Sep 17 00:00:00 2001 From: Dahan Gong Date: Thu, 17 Feb 2022 04:26:45 -0600 Subject: [PATCH] fix TENGINE_DUMP_DIR might not be treated as dir name (#1283) --- source/device/cpu/cpu_dump.c | 4 ++-- source/device/opendla/odla_dump.c | 4 ++-- source/device/tim-vx/timvx_dump.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/device/cpu/cpu_dump.c b/source/device/cpu/cpu_dump.c index 846155f2..59ff6849 100644 --- a/source/device/cpu/cpu_dump.c +++ b/source/device/cpu/cpu_dump.c @@ -533,11 +533,11 @@ void extract_feature_from_tensor(const char* comment, const char* layer_name, co const char* env_path = getenv(TENGINE_DUMP_DIR); - if (NULL != env_path && (256 - 2) > strlen(env_path)) + if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path)) { strcpy(save_dir, env_path); - if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)]) + if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1]) { #ifdef _MSC_VER save_dir[strlen(env_path)] = '\\'; diff --git a/source/device/opendla/odla_dump.c b/source/device/opendla/odla_dump.c index efe76c98..c3834e26 100644 --- a/source/device/opendla/odla_dump.c +++ b/source/device/opendla/odla_dump.c @@ -518,11 +518,11 @@ void extract_feature_from_tensor_odla(const char* comment, const char* layer_nam const char* env_path = getenv(TENGINE_DUMP_DIR); - if (NULL != env_path && (256 - 2) > strlen(env_path)) + if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path)) { strcpy(save_dir, env_path); - if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)]) + if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1]) { #ifdef _MSC_VER save_dir[strlen(env_path)] = '\\'; diff --git a/source/device/tim-vx/timvx_dump.c b/source/device/tim-vx/timvx_dump.c index 640e024e..5d802b77 100644 --- a/source/device/tim-vx/timvx_dump.c +++ b/source/device/tim-vx/timvx_dump.c @@ -458,11 +458,11 @@ void extract_feature_from_tensor_timvx(const char* comment, const char* layer_na const char* env_path = getenv(TENGINE_DUMP_DIR); - if (NULL != env_path && (256 - 2) > strlen(env_path)) + if (NULL != env_path && '\0' != env_path[0] && (256 - 2) > strlen(env_path)) { strcpy(save_dir, env_path); - if ('/' == save_dir[strlen(env_path)] || '\\' == save_dir[strlen(env_path)]) + if ('/' == save_dir[strlen(env_path) - 1] || '\\' == save_dir[strlen(env_path) - 1]) { #ifdef _MSC_VER save_dir[strlen(env_path)] = '\\'; -- GitLab