Skip to content

Commit daf768a

Browse files
committed
fix segfault
1 parent 3a89f67 commit daf768a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/pybind11/detail/internals.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ PYBIND11_NOINLINE internals &get_internals() {
445445
}
446446
}
447447

448-
if (internals_pp) {
448+
if (internals_pp && *internals_pp) {
449449
// We loaded builtins through python's builtins, which means that our `error_already_set`
450450
// and `builtin_exception` may be different local classes than the ones set up in the
451451
// initial exception translator, below, so add another for our local exception classes.
@@ -457,7 +457,9 @@ PYBIND11_NOINLINE internals &get_internals() {
457457
(*internals_pp)->registered_exception_translators.push_front(&translate_local_exception);
458458
#endif
459459
} else {
460-
internals_pp = new internals *();
460+
if (!internals_pp) {
461+
internals_pp = new internals *();
462+
}
461463
auto *&internals_ptr = *internals_pp;
462464
internals_ptr = new internals();
463465
#if defined(WITH_THREAD)

0 commit comments

Comments
 (0)