Commit 3cf57e1
authored
[mypyc] Fix undefined behavior related to empty vecs (#21094)
We used to use `&vec.buf->items`, which causes undefined behavior for an
empty vec that can be triggered on GCC when using -O3, since `buf` is
NULL for an empty vec. Use `offsetof` instead to calculate struct field
offset, since it doesn't trigger UB if pointer is NULL.1 parent 0c3ffd4 commit 3cf57e1
3 files changed
+16
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
812 | 815 | | |
813 | | - | |
814 | | - | |
| 816 | + | |
| 817 | + | |
815 | 818 | | |
816 | 819 | | |
817 | 820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
| 763 | + | |
| 764 | + | |
764 | 765 | | |
765 | 766 | | |
766 | | - | |
| 767 | + | |
| 768 | + | |
767 | 769 | | |
768 | 770 | | |
769 | | - | |
| 771 | + | |
| 772 | + | |
770 | 773 | | |
771 | 774 | | |
772 | 775 | | |
| |||
0 commit comments