Commit a8b1f7c
Jonathan Powell
Fix segfault when accessing fields/field_types on freed result
Add resultFreed check to rb_mysql_result_fetch_fields and
rb_mysql_result_fetch_field_types before accessing wrapper->result.
The segfault occurs when:
1. A query returns 0 rows
2. Internal row caching iterates (0 iterations), never populating wrapper->fields
3. Result is freed after iteration completes
4. .fields is called, wrapper->fields is Qnil
5. mysql_num_fields(wrapper->result) accesses freed memory -> SEGFAULT
This check already exists in other functions (e.g., rb_mysql_result_each_)
but was missing in the fields accessor functions.
Based on fix for #14261 parent c79b3c1 commit a8b1f7c
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
939 | 939 | | |
940 | 940 | | |
941 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
942 | 945 | | |
943 | 946 | | |
944 | 947 | | |
| |||
958 | 961 | | |
959 | 962 | | |
960 | 963 | | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
961 | 967 | | |
962 | 968 | | |
963 | 969 | | |
| |||
0 commit comments