Commit 9f3a4ec
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 9cba47d commit 9f3a4ec
1 file changed
+34
-8
lines changed| 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