File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/platforms/esp32/components/avm_sys Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -677,12 +677,12 @@ static void *select_thread_loop(void *arg)
677
677
{
678
678
GlobalContext * glb = arg ;
679
679
struct ESP32PlatformData * platform = glb -> platform_data ;
680
- struct pollfd * fds = malloc ( 0 ) ;
680
+ struct pollfd * fds = NULL ;
681
681
while (!platform -> select_thread_exit ) {
682
682
int select_events_poll_count = platform -> select_events_poll_count ;
683
683
int poll_count = 1 ;
684
684
int fd_index ;
685
- if (select_events_poll_count < 0 ) {
685
+ if (fds == NULL || select_events_poll_count < 0 ) {
686
686
// Means it is dirty and should be rebuilt.
687
687
struct ListHead * select_events = synclist_wrlock (& glb -> select_events );
688
688
size_t select_events_new_count ;
@@ -692,7 +692,11 @@ static void *select_thread_loop(void *arg)
692
692
select_events_new_count = select_events_poll_count ;
693
693
}
694
694
695
- fds = realloc (fds , sizeof (struct pollfd ) * (poll_count + select_events_new_count ));
695
+ if (fds ) {
696
+ fds = realloc (fds , sizeof (struct pollfd ) * (poll_count + select_events_new_count ));
697
+ } else {
698
+ fds = malloc (sizeof (struct pollfd ) * (poll_count + select_events_new_count ));
699
+ }
696
700
697
701
fds [0 ].fd = platform -> signal_fd ;
698
702
fds [0 ].events = POLLIN ;
You can’t perform that action at this time.
0 commit comments