]> granicus.if.org Git - vim/commitdiff
patch 8.1.0349: crash when wiping buffer in a callback v8.1.0349
authorBram Moolenaar <Bram@vim.org>
Thu, 6 Sep 2018 11:14:43 +0000 (13:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 6 Sep 2018 11:14:43 +0000 (13:14 +0200)
Problem:    Crash when wiping buffer in a callback.
Solution:   Do not handle messages when only peeking for a character.
            (closes #2107)  Add "redraw_flag" to test_override().

runtime/doc/eval.txt
src/evalfunc.c
src/globals.h
src/os_unix.c
src/os_win32.c
src/screen.c
src/version.c

index 640816521429b7ce8cbaccd77b9ce5d19e4e22c7..d51b92ce5f1ece6712a9ca22f6de4c5cc000d43c 100644 (file)
@@ -8737,6 +8737,7 @@ test_override({name}, {val})                              *test_override()*
 
                name         effect when {val} is non-zero ~
                redraw       disable the redrawing() function
+               redraw_flag  ignore the RedrawingDisabled flag
                char_avail   disable the char_avail() function
                starting     reset the "starting" variable, see below
                nfa_fail     makes the NFA regexp engine fail to force a
index 8a1fcef14b154efeffe0947974e739a230a63b8c..90fb8881b4375d804c0ea8a205ac8fc58f7ad329 100644 (file)
@@ -13073,6 +13073,8 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
 
        if (STRCMP(name, (char_u *)"redraw") == 0)
            disable_redraw_for_testing = val;
+       else if (STRCMP(name, (char_u *)"redraw_flag") == 0)
+           ignore_redraw_flag_for_testing = val;
        else if (STRCMP(name, (char_u *)"char_avail") == 0)
            disable_char_avail_for_testing = val;
        else if (STRCMP(name, (char_u *)"starting") == 0)
@@ -13095,6 +13097,7 @@ f_test_override(typval_T *argvars, typval_T *rettv UNUSED)
        {
            disable_char_avail_for_testing = FALSE;
            disable_redraw_for_testing = FALSE;
+           ignore_redraw_flag_for_testing = FALSE;
            nfa_fail_for_testing = FALSE;
            if (save_starting >= 0)
            {
index fa5b493e8a4bb5ebb2e98e437f4709f06babf60b..3446cba751ba64ca3fa9c6299e6fa23aa3d72289 100644 (file)
@@ -1633,9 +1633,10 @@ EXTERN int  alloc_fail_countdown INIT(= -1);
 EXTERN int  alloc_fail_repeat INIT(= 0);
 
 /* flags set by test_override() */
-EXTERN int  disable_char_avail_for_testing INIT(= 0);
-EXTERN int  disable_redraw_for_testing INIT(= 0);
-EXTERN int  nfa_fail_for_testing INIT(= 0);
+EXTERN int  disable_char_avail_for_testing INIT(= FALSE);
+EXTERN int  disable_redraw_for_testing INIT(= FALSE);
+EXTERN int  ignore_redraw_flag_for_testing INIT(= FALSE);
+EXTERN int  nfa_fail_for_testing INIT(= FALSE);
 
 EXTERN int  in_free_unref_items INIT(= FALSE);
 #endif
index 99662218b641949746f65c17b7c3ee9ce1548aec..f33042675da49772d9fed13bc7bde7d51d9bf219 100644 (file)
@@ -417,10 +417,14 @@ mch_inchar(
            handle_resize();
 
 #ifdef MESSAGE_QUEUE
-       parse_queued_messages();
-       /* If input was put directly in typeahead buffer bail out here. */
-       if (typebuf_changed(tb_change_cnt))
-           return 0;
+       // Only process messages when waiting.
+       if (wtime != 0)
+       {
+           parse_queued_messages();
+           // If input was put directly in typeahead buffer bail out here.
+           if (typebuf_changed(tb_change_cnt))
+               return 0;
+       }
 #endif
        if (wtime < 0 && did_start_blocking)
            /* blocking and already waited for p_ut */
index 02bcaaede9cf6db52c334a6ee433eb89b84d214c..9d36dec4a5e2b77cc0882170fca92508c5db7709 100644 (file)
@@ -1529,15 +1529,19 @@ WaitForChar(long msec, int ignore_input)
      */
     for (;;)
     {
+       // Only process messages when waiting.
+       if (msec != 0)
+       {
 #ifdef MESSAGE_QUEUE
-       parse_queued_messages();
+           parse_queued_messages();
 #endif
 #ifdef FEAT_MZSCHEME
-       mzvim_check_threads();
+           mzvim_check_threads();
 #endif
 #ifdef FEAT_CLIENTSERVER
-       serverProcessPendingMessages();
+           serverProcessPendingMessages();
 #endif
+       }
 
        if (0
 #ifdef FEAT_MOUSE
index 743c321c476b00ab37709b2251acc6c99e494e17..c9f9410b6a7b1e195561ba9df4ee1bb83cf99495 100644 (file)
@@ -10819,8 +10819,11 @@ redrawing(void)
        return 0;
     else
 #endif
-       return (!RedrawingDisabled
-                      && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
+       return ((!RedrawingDisabled
+#ifdef FEAT_EVAL
+                   || ignore_redraw_flag_for_testing
+#endif
+               ) && !(p_lz && char_avail() && !KeyTyped && !do_redraw));
 }
 
 /*
index ab77c136539d5aedb8e047106abfc672c9b48751..9e399a656df1391a326374dceeca97de5e8bcf9d 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    349,
 /**/
     348,
 /**/