@@ -278,18 +278,20 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
278278 case CORE_UPDATER_LIST_BEGIN :
279279 {
280280 char buildbot_url [PATH_MAX_LENGTH ];
281- settings_t * settings = config_get_ptr ();
282- file_transfer_t * transf = NULL ;
283- char * tmp_url = NULL ;
284- const char * net_buildbot_url =
285- settings -> paths .network_buildbot_url ;
281+ settings_t * settings = config_get_ptr ();
282+ file_transfer_t * transf = NULL ;
283+ const char * net_buildbot_url ;
286284
287285 /* Reset core updater list */
288286 core_updater_list_reset (list_handle -> core_list );
289- /* Get core listing URL */
287+
288+ /* Get core listing URL - check settings first to
289+ * avoid dereferencing NULL */
290290 if (!settings )
291291 goto task_finished ;
292292
293+ net_buildbot_url = settings -> paths .network_buildbot_url ;
294+
293295 if (string_is_empty (net_buildbot_url ))
294296 goto task_finished ;
295297
@@ -299,12 +301,15 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
299301 ".index-extended" ,
300302 sizeof (buildbot_url ));
301303
302- tmp_url = strdup (buildbot_url );
303- buildbot_url [0 ] = '\0' ;
304- net_http_urlencode_full (
305- buildbot_url , tmp_url , sizeof (buildbot_url ));
306- if (tmp_url )
307- free (tmp_url );
304+ /* URL-encode in place using a stack buffer
305+ * instead of heap-allocating a copy */
306+ {
307+ char tmp_url [PATH_MAX_LENGTH ];
308+ strlcpy (tmp_url , buildbot_url , sizeof (tmp_url ));
309+ buildbot_url [0 ] = '\0' ;
310+ net_http_urlencode_full (
311+ buildbot_url , tmp_url , sizeof (buildbot_url ));
312+ }
308313
309314 if (string_is_empty (buildbot_url ))
310315 goto task_finished ;
@@ -314,10 +319,7 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
314319 sizeof (file_transfer_t ))))
315320 goto task_finished ;
316321
317- /* > Seems to be required - not sure why the
318- * underlying code is implemented like this... */
319322 strlcpy (transf -> path , buildbot_url , sizeof (transf -> path ));
320-
321323 transf -> user_data = (void * )list_handle ;
322324
323325 /* Push HTTP transfer task */
@@ -342,10 +344,8 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
342344 {
343345 uint8_t _flg = task_get_flags (list_handle -> http_task );
344346
345- if ((_flg & (RETRO_TASK_FLG_FINISHED )) > 0 )
346- list_handle -> http_task_finished = true;
347- else
348- list_handle -> http_task_finished = false;
347+ list_handle -> http_task_finished =
348+ ((_flg & RETRO_TASK_FLG_FINISHED ) > 0 );
349349
350350 /* If HTTP task is running, copy current
351351 * progress value to *this* task */
@@ -362,20 +362,22 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
362362 break ;
363363 case CORE_UPDATER_LIST_END :
364364 {
365- settings_t * settings = config_get_ptr ();
366-
367365 /* Check whether HTTP task was successful */
368366 if (list_handle -> http_task_success )
369367 {
370368 /* Parse HTTP transfer data */
371369 if (list_handle -> http_data )
372- core_updater_list_parse_network_data (
373- list_handle -> core_list ,
374- settings -> paths .directory_libretro ,
375- settings -> paths .path_libretro_info ,
376- settings -> paths .network_buildbot_url ,
377- list_handle -> http_data -> data ,
378- list_handle -> http_data -> len );
370+ {
371+ settings_t * settings = config_get_ptr ();
372+ if (settings )
373+ core_updater_list_parse_network_data (
374+ list_handle -> core_list ,
375+ settings -> paths .directory_libretro ,
376+ settings -> paths .path_libretro_info ,
377+ settings -> paths .network_buildbot_url ,
378+ list_handle -> http_data -> data ,
379+ list_handle -> http_data -> len );
380+ }
379381 }
380382 else
381383 {
@@ -386,7 +388,6 @@ static void task_core_updater_get_list_handler(retro_task_t *task)
386388
387389 /* Enable menu refresh, if required */
388390#if defined(RARCH_INTERNAL ) && defined(HAVE_MENU )
389- if (list_handle -> refresh_menu )
390391 {
391392 struct menu_state * menu_st = menu_state_get_ptr ();
392393 if (list_handle -> refresh_menu )
0 commit comments