pebble-dev / RebbleOS

open source operating system for low-power smartwatches
Other
355 stars 38 forks source link

events: fix double free with multiple subscribers #160

Open frbncis opened 3 years ago

frbncis commented 3 years ago

This fixes a double free that occurs when you have multiple subscribers on the same event on the app and overlay threads.

If we have two subscribers (one in the app thread and one in the overlay thread), then the event was being posted to the overlay thread for every subscriber - thus the packet was being destroyed twice

This was encountered when adding a subscriber in notification.c for new notifications.

With this change, subscribers are executed first, then a single post to the overlay thread is made.