Commit 533bf74
committed
Fix resource initialization order to prevent UB in destructor
Move tw_init(&conn->cancel_tw) before interrupt_mutex creation.
If interrupt_mutex creation fails, enif_release_resource triggers
the destructor, which calls tw_destroy on conn->cancel_tw. Without
this change, tw_destroy would be called on an uninitialized condvar.1 parent f302f47 commit 533bf74
1 file changed
Lines changed: 10 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
551 | | - | |
| 551 | + | |
552 | 552 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | 553 | | |
559 | | - | |
| 554 | + | |
| 555 | + | |
560 | 556 | | |
561 | 557 | | |
562 | 558 | | |
563 | 559 | | |
564 | 560 | | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
565 | 568 | | |
566 | 569 | | |
567 | 570 | | |
| |||
0 commit comments