Commit bc3ce76
committed
ctypes: Correctly handle NULL dlsym values
For dlsym(), a return value of NULL does not necessarily indicate
an error [1].
Therefore, to avoid using stale (or NULL) dlerror() values, we must:
1. clear the previous error state by calling dlerror()
2. call dlsym()
3. call dlerror()
If the return value of dlerror() is not NULL, an error occured.
In our case, we also subjectively treat a NULL return value
from dlsym() as an error, so we format a special string for that.
[1]: https://man7.org/linux/man-pages/man3/dlsym.3.html
Signed-off-by: Georgios Alexopoulos <grgalex42@gmail.com>1 parent 09d6f5d commit bc3ce76
File tree
2 files changed
+35
-8
lines changed- Misc/NEWS.d/next/C_API
- Modules/_ctypes
2 files changed
+35
-8
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| 937 | + | |
937 | 938 | | |
938 | 939 | | |
939 | 940 | | |
| |||
967 | 968 | | |
968 | 969 | | |
969 | 970 | | |
| 971 | + | |
970 | 972 | | |
971 | | - | |
972 | 973 | | |
973 | | - | |
| 974 | + | |
| 975 | + | |
974 | 976 | | |
975 | 977 | | |
976 | 978 | | |
| 979 | + | |
| 980 | + | |
977 | 981 | | |
978 | | - | |
979 | | - | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
980 | 991 | | |
981 | 992 | | |
| 993 | + | |
982 | 994 | | |
983 | 995 | | |
984 | 996 | | |
| |||
3706 | 3718 | | |
3707 | 3719 | | |
3708 | 3720 | | |
| 3721 | + | |
3709 | 3722 | | |
3710 | 3723 | | |
3711 | 3724 | | |
| |||
3774 | 3787 | | |
3775 | 3788 | | |
3776 | 3789 | | |
| 3790 | + | |
3777 | 3791 | | |
3778 | | - | |
3779 | 3792 | | |
3780 | | - | |
| 3793 | + | |
| 3794 | + | |
3781 | 3795 | | |
3782 | 3796 | | |
3783 | 3797 | | |
| 3798 | + | |
| 3799 | + | |
| 3800 | + | |
3784 | 3801 | | |
3785 | | - | |
3786 | | - | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
| 3806 | + | |
| 3807 | + | |
| 3808 | + | |
| 3809 | + | |
| 3810 | + | |
| 3811 | + | |
3787 | 3812 | | |
3788 | 3813 | | |
3789 | 3814 | | |
| 3815 | + | |
3790 | 3816 | | |
3791 | 3817 | | |
3792 | 3818 | | |
| |||
0 commit comments