diff --git a/openmp/runtime/src/kmp_itt.inl b/openmp/runtime/src/kmp_itt.inl --- a/openmp/runtime/src/kmp_itt.inl +++ b/openmp/runtime/src/kmp_itt.inl @@ -365,25 +365,30 @@ } // Parse line and column from psource string: ";file;func;line;col;;" + kmp_uint64 loop_data[5]; char *s_line; - char *s_col; + char *s_col = NULL; KMP_DEBUG_ASSERT(loc->psource); #ifdef __cplusplus s_line = strchr(CCAST(char *, loc->psource), ';'); #else s_line = strchr(loc->psource, ';'); #endif - KMP_DEBUG_ASSERT(s_line); - s_line = strchr(s_line + 1, ';'); // 2-nd semicolon - KMP_DEBUG_ASSERT(s_line); - s_line = strchr(s_line + 1, ';'); // 3-rd semicolon - KMP_DEBUG_ASSERT(s_line); - s_col = strchr(s_line + 1, ';'); // 4-th semicolon - KMP_DEBUG_ASSERT(s_col); - - kmp_uint64 loop_data[5]; - loop_data[0] = atoi(s_line + 1); // read line - loop_data[1] = atoi(s_col + 1); // read column + // check pointers in case the format of psource is broken + if (s_line) + s_line = strchr(s_line + 1, ';'); // 2-nd semicolon + if (s_line) + s_line = strchr(s_line + 1, ';'); // 3-rd semicolon + if (s_line) { + loop_data[0] = atoi(s_line + 1); // read line # + s_col = strchr(s_line + 1, ';'); // 4-th semicolon + } else { + loop_data[0] = 0; + } + if (s_col) + loop_data[1] = atoi(s_col + 1); // read column # + else + loop_data[1] = 0; loop_data[2] = sched_type; loop_data[3] = iterations; loop_data[4] = chunk;