@@ -537,7 +537,7 @@ set_string_option(
537537 saved_newval = vim_strsave (s );
538538 }
539539#endif
540- if ((errmsg = did_set_string_option (opt_idx , varp , TRUE, oldval , NULL ,
540+ if ((errmsg = did_set_string_option (opt_idx , varp , oldval , NULL ,
541541 opt_flags , & value_checked )) == NULL )
542542 did_set_option (opt_idx , opt_flags , TRUE, value_checked );
543543
@@ -639,13 +639,13 @@ check_stl_option(char_u *s)
639639
640640/*
641641 * Handle string options that need some action to perform when changed.
642+ * The new value must be allocated.
642643 * Returns NULL for success, or an unstranslated error message for an error.
643644 */
644645 char *
645646did_set_string_option (
646647 int opt_idx , // index in options[] table
647648 char_u * * varp , // pointer to the option variable
648- int new_value_alloced , // new value was allocated
649649 char_u * oldval , // previous value of the option
650650 char * errbuf , // buffer for errors, or NULL
651651 int opt_flags , // OPT_LOCAL and/or OPT_GLOBAL
@@ -1188,10 +1188,8 @@ did_set_string_option(
11881188 // When setting the global value to empty, make it "zip".
11891189 if (* p_cm == NUL )
11901190 {
1191- if (new_value_alloced )
1192- free_string_option (p_cm );
1191+ free_string_option (p_cm );
11931192 p_cm = vim_strsave ((char_u * )"zip" );
1194- new_value_alloced = TRUE;
11951193 }
11961194 // When using ":set cm=name" the local value is going to be empty.
11971195 // Do that here, otherwise the crypt functions will still use the
@@ -1441,8 +1439,7 @@ did_set_string_option(
14411439 t_colors = colors ;
14421440 if (t_colors <= 1 )
14431441 {
1444- if (new_value_alloced )
1445- vim_free (T_CCO );
1442+ vim_free (T_CCO );
14461443 T_CCO = empty_option ;
14471444 }
14481445#if defined(FEAT_VTP ) && defined(FEAT_TERMGUICOLORS )
@@ -1511,12 +1508,8 @@ did_set_string_option(
15111508 if (STRCMP (p , "*" ) == 0 )
15121509 {
15131510 p = gui_mch_font_dialog (oldval );
1514-
1515- if (new_value_alloced )
1516- free_string_option (p_guifont );
1517-
1511+ free_string_option (p_guifont );
15181512 p_guifont = (p != NULL ) ? p : vim_strsave (oldval );
1519- new_value_alloced = TRUE;
15201513 }
15211514# endif
15221515 if (p != NULL && gui_init_font (p_guifont , FALSE) != OK )
@@ -1526,10 +1519,8 @@ did_set_string_option(
15261519 {
15271520 // Dialog was cancelled: Keep the old value without giving
15281521 // an error message.
1529- if (new_value_alloced )
1530- free_string_option (p_guifont );
1522+ free_string_option (p_guifont );
15311523 p_guifont = vim_strsave (oldval );
1532- new_value_alloced = TRUE;
15331524 }
15341525 else
15351526# endif
@@ -1950,10 +1941,8 @@ did_set_string_option(
19501941 REPTERM_FROM_PART | REPTERM_DO_LT , NULL );
19511942 if (p != NULL )
19521943 {
1953- if (new_value_alloced )
1954- free_string_option (p_pt );
1944+ free_string_option (p_pt );
19551945 p_pt = p ;
1956- new_value_alloced = TRUE;
19571946 }
19581947 }
19591948 }
@@ -2369,10 +2358,8 @@ did_set_string_option(
23692358 name = get_scriptlocal_funcname (* p_opt );
23702359 if (name != NULL )
23712360 {
2372- if (new_value_alloced )
2373- free_string_option (* p_opt );
2361+ free_string_option (* p_opt );
23742362 * p_opt = name ;
2375- new_value_alloced = TRUE;
23762363 }
23772364 }
23782365
@@ -2486,8 +2473,7 @@ did_set_string_option(
24862473 // If error detected, restore the previous value.
24872474 if (errmsg != NULL )
24882475 {
2489- if (new_value_alloced )
2490- free_string_option (* varp );
2476+ free_string_option (* varp );
24912477 * varp = oldval ;
24922478 // When resetting some values, need to act on it.
24932479 if (did_chartab )
@@ -2506,10 +2492,7 @@ did_set_string_option(
25062492 // our fingers (esp. init_highlight()).
25072493 if (free_oldval )
25082494 free_string_option (oldval );
2509- if (new_value_alloced )
2510- set_option_flag (opt_idx , P_ALLOCED );
2511- else
2512- clear_option_flag (opt_idx , P_ALLOCED );
2495+ set_option_flag (opt_idx , P_ALLOCED );
25132496
25142497 if ((opt_flags & (OPT_LOCAL | OPT_GLOBAL )) == 0
25152498 && is_global_local_option (opt_idx ))
0 commit comments