Commit 21f5bf8
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 ae4ee81 commit 21f5bf8
1 file changed
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
546 | 554 | | |
547 | 555 | | |
548 | | - | |
| 556 | + | |
549 | 557 | | |
550 | 558 | | |
551 | 559 | | |
552 | 560 | | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | 561 | | |
560 | 562 | | |
561 | 563 | | |
| |||
0 commit comments