[Openmp-commits] [openmp] [OpenMP] Make sure ptr is used after NULL check (PR #83304)
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Wed Feb 28 09:34:57 PST 2024
https://github.com/jpeyton52 created https://github.com/llvm/llvm-project/pull/83304
None
>From 6975de8831c88a25063f748f808a0f44fa5f0f72 Mon Sep 17 00:00:00 2001
From: Jonathan Peyton <jonathan.l.peyton at intel.com>
Date: Tue, 27 Feb 2024 17:15:31 -0600
Subject: [PATCH] [OpenMP] Make sure ptr is used after NULL check
---
openmp/runtime/src/kmp_settings.cpp | 4 ++--
openmp/runtime/src/kmp_threadprivate.cpp | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/openmp/runtime/src/kmp_settings.cpp b/openmp/runtime/src/kmp_settings.cpp
index ec86ee07472c1e..3516c050502ce4 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