mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	vim-patch:7.4.1567
Problem:    Crash in assert_fails().
Solution:   Check for NULL. (Dominique Pelle)  Add a test.
1abb502635
			
			
This commit is contained in:
		@@ -7688,7 +7688,8 @@ static void f_assert_fails(typval_T *argvars, typval_T *rettv)
 | 
				
			|||||||
    char_u buf[NUMBUFLEN];
 | 
					    char_u buf[NUMBUFLEN];
 | 
				
			||||||
    char *error = (char *)get_tv_string_buf_chk(&argvars[1], buf);
 | 
					    char *error = (char *)get_tv_string_buf_chk(&argvars[1], buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (strstr((char *)vimvars[VV_ERRMSG].vv_str, error) == NULL) {
 | 
					    if (error == NULL
 | 
				
			||||||
 | 
					        || strstr((char *)vimvars[VV_ERRMSG].vv_str, error) == NULL) {
 | 
				
			||||||
      prepare_assert_error(&ga);
 | 
					      prepare_assert_error(&ga);
 | 
				
			||||||
      fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
 | 
					      fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
 | 
				
			||||||
                        &vimvars[VV_ERRMSG].vv_tv);
 | 
					                        &vimvars[VV_ERRMSG].vv_tv);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -119,7 +119,7 @@ static int included_patches[] = {
 | 
				
			|||||||
  1570,
 | 
					  1570,
 | 
				
			||||||
  1569,
 | 
					  1569,
 | 
				
			||||||
  1568,
 | 
					  1568,
 | 
				
			||||||
  // 1567,
 | 
					  1567,
 | 
				
			||||||
  // 1566 NA
 | 
					  // 1566 NA
 | 
				
			||||||
  // 1565,
 | 
					  // 1565,
 | 
				
			||||||
  // 1564,
 | 
					  // 1564,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -142,4 +142,22 @@ describe('assert function:', function()
 | 
				
			|||||||
      })
 | 
					      })
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
  end)
 | 
					  end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  -- assert_fails({cmd}, [, {error}])
 | 
				
			||||||
 | 
					  describe('assert_fails', function()
 | 
				
			||||||
 | 
					    it('should change v:errors when error does not match v:errmsg', function()
 | 
				
			||||||
 | 
					      execute([[call assert_fails('xxx', {})]])
 | 
				
			||||||
 | 
					      expected_errors({"Expected {} but got 'E731: using Dictionary as a String'"})
 | 
				
			||||||
 | 
					    end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should not change v:errors when cmd errors', function()
 | 
				
			||||||
 | 
					      call('assert_fails', 'NonexistentCmd')
 | 
				
			||||||
 | 
					      expected_empty()
 | 
				
			||||||
 | 
					    end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('should change v:errors when cmd succeeds', function()
 | 
				
			||||||
 | 
					      call('assert_fails', 'call empty("")')
 | 
				
			||||||
 | 
					      expected_errors({'command did not fail: call empty("")'})
 | 
				
			||||||
 | 
					    end)
 | 
				
			||||||
 | 
					  end)
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user