[Openmp-commits] [openmp] 1ed463d - [OpenMP] Make sure ptr is used after NULL check (#83304)

via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 11 08:27:35 PDT 2024


Author: Jonathan Peyton
Date: 2024-03-11T10:27:31-05:00
New Revision: 1ed463d9617324c37d7efe117233f68f794ac619

URL: https://github.com/llvm/llvm-project/commit/1ed463d9617324c37d7efe117233f68f794ac619
DIFF: https://github.com/llvm/llvm-project/commit/1ed463d9617324c37d7efe117233f68f794ac619.diff

LOG: [OpenMP] Make sure ptr is used after NULL check (#83304)

Added: 
    

Modified: 
    openmp/runtime/src/kmp_settings.cpp
    openmp/runtime/src/kmp_threadprivate.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index abca4d2d7525f5..b9c8289b5c51c0 100644
--- a/openmp/runtime/src/kmp_settings.cpp
+++ b/openmp/runtime/src/kmp_settings.cpp
@@ -4373,8 +4373,8 @@ static void __kmp_stg_parse_omp_schedule(char const *name, char const *value,
                                          void *data) {
   size_t length;
   const char *ptr = value;
-  SKIP_WS(ptr);
-  if (value) {
+  if (ptr) {
+    SKIP_WS(ptr);
     length = KMP_STRLEN(value);
     if (length) {
       if (value[length - 1] == '"' || value[length - 1] == '\'')

diff  --git a/openmp/runtime/src/kmp_threadprivate.cpp b/openmp/runtime/src/kmp_threadprivate.cpp
index b79ac7d6d2b254..c4a1ec6e10239a 100644
--- a/openmp/runtime/src/kmp_threadprivate.cpp
+++ b/openmp/runtime/src/kmp_threadprivate.cpp
@@ -248,16 +248,16 @@ void __kmp_common_destroy_gtid(int gtid) {
         if (d_tn->is_vec) {
           if (d_tn->dt.dtorv != 0) {
             (void)(*d_tn->dt.dtorv)(tn->par_addr, d_tn->vec_len);
-          }
-          if (d_tn->obj_init != 0) {
-            (void)(*d_tn->dt.dtorv)(d_tn->obj_init, d_tn->vec_len);
+            if (d_tn->obj_init != 0) {
+              (void)(*d_tn->dt.dtorv)(d_tn->obj_init, d_tn->vec_len);
+            }
           }
         } else {
           if (d_tn->dt.dtor != 0) {
             (void)(*d_tn->dt.dtor)(tn->par_addr);
-          }
-          if (d_tn->obj_init != 0) {
-            (void)(*d_tn->dt.dtor)(d_tn->obj_init);
+            if (d_tn->obj_init != 0) {
+              (void)(*d_tn->dt.dtor)(d_tn->obj_init);
+            }
           }
         }
       }


        


More information about the Openmp-commits mailing list