@@ -1124,7 +1124,7 @@ do_source(
11241124 // inode number, even though to the user it is the same script.
11251125 // - If a script is deleted and another script is written, with a
11261126 // different name, the inode may be re-used.
1127- si = & SCRIPT_ITEM (sid );
1127+ si = SCRIPT_ITEM (sid );
11281128 if (si -> sn_name != NULL && fnamecmp (si -> sn_name , fname_exp ) == 0 )
11291129 // Found it!
11301130 break ;
@@ -1294,8 +1294,11 @@ do_source(
12941294 goto almosttheend ;
12951295 while (script_items .ga_len < current_sctx .sc_sid )
12961296 {
1297+ si = ALLOC_CLEAR_ONE (scriptitem_T );
1298+ if (si == NULL )
1299+ goto almosttheend ;
12971300 ++ script_items .ga_len ;
1298- si = & SCRIPT_ITEM (script_items .ga_len );
1301+ SCRIPT_ITEM (script_items .ga_len ) = si ;
12991302 si -> sn_name = NULL ;
13001303 si -> sn_version = 1 ;
13011304
@@ -1308,7 +1311,7 @@ do_source(
13081311 si -> sn_prof_on = FALSE;
13091312# endif
13101313 }
1311- si = & SCRIPT_ITEM (current_sctx .sc_sid );
1314+ si = SCRIPT_ITEM (current_sctx .sc_sid );
13121315 si -> sn_name = fname_exp ;
13131316 fname_exp = vim_strsave (si -> sn_name ); // used for autocmd
13141317 if (ret_sid != NULL )
@@ -1364,7 +1367,7 @@ do_source(
13641367 if (do_profiling == PROF_YES )
13651368 {
13661369 // Get "si" again, "script_items" may have been reallocated.
1367- si = & SCRIPT_ITEM (current_sctx .sc_sid );
1370+ si = SCRIPT_ITEM (current_sctx .sc_sid );
13681371 if (si -> sn_prof_on )
13691372 {
13701373 profile_end (& si -> sn_pr_start );
@@ -1411,7 +1414,7 @@ do_source(
14111414#ifdef FEAT_EVAL
14121415almosttheend :
14131416 // Get "si" again, "script_items" may have been reallocated.
1414- si = & SCRIPT_ITEM (current_sctx .sc_sid );
1417+ si = SCRIPT_ITEM (current_sctx .sc_sid );
14151418 if (si -> sn_save_cpo != NULL )
14161419 {
14171420 free_string_option (p_cpo );
@@ -1456,16 +1459,16 @@ ex_scriptnames(exarg_T *eap)
14561459 emsg (_ (e_invarg ));
14571460 else
14581461 {
1459- eap -> arg = SCRIPT_ITEM (eap -> line2 ). sn_name ;
1462+ eap -> arg = SCRIPT_ITEM (eap -> line2 )-> sn_name ;
14601463 do_exedit (eap , NULL );
14611464 }
14621465 return ;
14631466 }
14641467
14651468 for (i = 1 ; i <= script_items .ga_len && !got_int ; ++ i )
1466- if (SCRIPT_ITEM (i ). sn_name != NULL )
1469+ if (SCRIPT_ITEM (i )-> sn_name != NULL )
14671470 {
1468- home_replace (NULL , SCRIPT_ITEM (i ). sn_name ,
1471+ home_replace (NULL , SCRIPT_ITEM (i )-> sn_name ,
14691472 NameBuff , MAXPATHL , TRUE);
14701473 smsg ("%3d: %s" , i , NameBuff );
14711474 }
@@ -1481,8 +1484,8 @@ scriptnames_slash_adjust(void)
14811484 int i ;
14821485
14831486 for (i = 1 ; i <= script_items .ga_len ; ++ i )
1484- if (SCRIPT_ITEM (i ). sn_name != NULL )
1485- slash_adjust (SCRIPT_ITEM (i ). sn_name );
1487+ if (SCRIPT_ITEM (i )-> sn_name != NULL )
1488+ slash_adjust (SCRIPT_ITEM (i )-> sn_name );
14861489}
14871490# endif
14881491
@@ -1502,7 +1505,7 @@ get_scriptname(scid_T id)
15021505 return (char_u * )_ ("environment variable" );
15031506 if (id == SID_ERROR )
15041507 return (char_u * )_ ("error handler" );
1505- return SCRIPT_ITEM (id ). sn_name ;
1508+ return SCRIPT_ITEM (id )-> sn_name ;
15061509}
15071510
15081511# if defined(EXITFREE ) || defined(PROTO )
@@ -1513,14 +1516,17 @@ free_scriptnames(void)
15131516
15141517 for (i = script_items .ga_len ; i > 0 ; -- i )
15151518 {
1519+ scriptitem_T * si = SCRIPT_ITEM (i );
1520+
15161521 // the variables themselves are cleared in evalvars_clear()
1517- vim_free (SCRIPT_ITEM ( i ). sn_vars );
1522+ vim_free (si -> sn_vars );
15181523
1519- vim_free (SCRIPT_ITEM ( i ). sn_name );
1520- free_string_option (SCRIPT_ITEM ( i ). sn_save_cpo );
1524+ vim_free (si -> sn_name );
1525+ free_string_option (si -> sn_save_cpo );
15211526# ifdef FEAT_PROFILE
1522- ga_clear (& SCRIPT_ITEM ( i ). sn_prl_ga );
1527+ ga_clear (& si -> sn_prl_ga );
15231528# endif
1529+ vim_free (si );
15241530 }
15251531 ga_clear (& script_items );
15261532}
@@ -1832,7 +1838,7 @@ ex_scriptversion(exarg_T *eap UNUSED)
18321838 else
18331839 {
18341840 current_sctx .sc_version = nr ;
1835- SCRIPT_ITEM (current_sctx .sc_sid ). sn_version = nr ;
1841+ SCRIPT_ITEM (current_sctx .sc_sid )-> sn_version = nr ;
18361842 }
18371843#endif
18381844}
0 commit comments