Skip to content

Commit

Permalink
use reinterpret_cast instead C-style to load symbols with dlsym to pr…
Browse files Browse the repository at this point in the history
…event UB
  • Loading branch information
mindhells authored and DX-MON committed May 7, 2020
1 parent ec41181 commit c5209eb
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/cpp/custom_formula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main() {
return -1;
}
pf_obj *(*pfn)(void);
pfn = (pf_obj * (*)(void)) dlsym(lib_handle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(lib_handle, "pf_new"));
if (!pfn)
{
fprintf(stderr, "Error loading formula symbols: %s", dlerror());
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/multithread_mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int main() {
return -1;
}
pf_obj *(*pfn)(void);
pfn = (pf_obj * (*)(void)) dlsym(lib_handle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(lib_handle, "pf_new"));
if (!pfn)
{
fprintf(stderr, "Error loading formula symbols: %s", dlerror());
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/raw_mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main() {
return -1;
}
pf_obj *(*pfn)(void);
pfn = (pf_obj * (*)(void)) dlsym(lib_handle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(lib_handle, "pf_new"));
if (!pfn)
{
fprintf(stderr, "Error loading formula symbols: %s", dlerror());
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/simple_mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int main() {
return -1;
}
pf_obj *(*pfn)(void);
pfn = (pf_obj * (*)(void)) dlsym(lib_handle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(lib_handle, "pf_new"));
if (!pfn)
{
fprintf(stderr, "Error loading formula symbols: %s", dlerror());
Expand Down
2 changes: 1 addition & 1 deletion fract4d/c/fract4dc/controllers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ namespace controllers

// create the point function handler from dynamic library
pf_obj *(*pfn)(void);
pfn = (pf_obj * (*)(void)) dlsym(lib_handle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(lib_handle, "pf_new"));
if (!pfn)
{
PyErr_SetString(PyExc_ValueError, dlerror());
Expand Down
2 changes: 1 addition & 1 deletion fract4d/c/fract4dc/loaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace loaders
}

dlHandle = module_fromcapsule(pyobj);
pfn = (pf_obj * (*)(void)) dlsym(dlHandle, "pf_new");
pfn = reinterpret_cast<pf_obj * (*)(void)>(dlsym(dlHandle, "pf_new"));
if (NULL == pfn)
{
PyErr_SetString(PyExc_ValueError, dlerror());
Expand Down

0 comments on commit c5209eb

Please sign in to comment.