[vlc-commits] [Git][videolan/vlc][3.0.x] Lua : replace recursive logic with iterative approach
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Mon Apr 21 07:28:58 UTC 2025
Felix Paul Kühne pushed to branch 3.0.x at VideoLAN / VLC
Commits:
82b241ee by Kartik Dua at 2025-04-21T07:06:48+00:00
Lua : replace recursive logic with iterative approach
Converted recursive implementation to an iterative one to prevent
stack overflows from deeply nested calls. This enhances stability
and ensures safer execution for long sequences.
(cherry picked from commit 33e05c8474f431fe735826961e89b38b9f4e3664)
- - - - -
1 changed file:
- modules/lua/extension_thread.c
Changes:
=====================================
modules/lua/extension_thread.c
=====================================
@@ -91,28 +91,27 @@ int Activate( extensions_manager_t *p_mgr, extension_t *p_ext )
return VLC_SUCCESS;
}
-/** Recursively drop and free commands starting from "command" */
static void FreeCommands( struct command_t *command )
{
- if( !command ) return;
- struct command_t *next = command->next;
- switch( command->i_command )
- {
- case CMD_ACTIVATE:
- case CMD_DEACTIVATE:
- case CMD_CLICK: // Arg1 must not be freed
- break;
-
- case CMD_TRIGGERMENU:
- case CMD_PLAYING_CHANGED:
- free( command->data[0] ); // Arg1 is int*, to free
- break;
-
- default:
- break;
+ while (command) {
+ struct command_t *next = command->next;
+ switch( command->i_command )
+ {
+ case CMD_ACTIVATE:
+ case CMD_DEACTIVATE:
+ case CMD_CLICK:
+ /* No extra memory to free */
+ break;
+ case CMD_TRIGGERMENU:
+ case CMD_PLAYING_CHANGED:
+ free( command->data[0] ); // free allocated data
+ break;
+ default:
+ break;
+ }
+ free(command);
+ command = next;
}
- free( command );
- FreeCommands( next );
}
bool QueueDeactivateCommand( extension_t *p_ext )
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/82b241ee2bdffa1fbaa0d4fd3d7dc522e2f9b1d6
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/82b241ee2bdffa1fbaa0d4fd3d7dc522e2f9b1d6
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list