@@ -958,6 +958,58 @@ func Nb_bwipe_buffer(port)
958958 sleep 10 m
959959endfunc
960960
961+ func Nb_specialKeys_overflow (port)
962+ call delete (" Xnetbeans" )
963+ call writefile ([], " Xnetbeans" )
964+
965+ " Last line number in the Xnetbeans file. Used to verify the result of the
966+ " communication with the netbeans server
967+ let g: last = 0
968+
969+ " Establish the connection with the netbeans server
970+ exe ' nbstart :localhost:' .. a: port .. ' :bunny'
971+ call WaitFor (' len(ReadXnetbeans()) > (g:last + 2)' )
972+ let l = ReadXnetbeans ()
973+ call assert_equal ([' AUTH bunny' ,
974+ \ ' 0:version=0 "2.5"' ,
975+ \ ' 0:startupDone=0' ], l [-3 :])
976+ let g: last += 3
977+
978+ " Open the command buffer to communicate with the server
979+ split Xcmdbuf
980+ let cmdbufnr = bufnr ()
981+ call WaitFor (' len(ReadXnetbeans()) > (g:last + 2)' )
982+ let l = ReadXnetbeans ()
983+ call assert_equal (' 0:fileOpened=0 "Xcmdbuf" T F' ,
984+ \ substitute (l [-3 ], ' ".*/' , ' "' , ' ' ))
985+ call assert_equal (' send: 1:putBufferNumber!15 "Xcmdbuf"' ,
986+ \ substitute (l [-2 ], ' ".*/' , ' "' , ' ' ))
987+ call assert_equal (' 1:startDocumentListen!16' , l [-1 ])
988+ let g: last += 3
989+
990+ " Keep the command buffer loaded for communication
991+ hide
992+
993+ sleep 1 m
994+
995+ " Open the command buffer to communicate with the server
996+ split Xcmdbuf
997+ let cmdbufnr = bufnr ()
998+ call appendbufline (cmdbufnr, ' $' , ' specialKeys_overflow_Test' )
999+ call WaitFor (' len(ReadXnetbeans()) >= (g:last + 6)' )
1000+ call WaitForAssert ({- > assert_match (' send: 0:specialKeys!200 "A\{80}-X"' ,
1001+ \ ReadXnetbeans ()[-1 ])})
1002+
1003+ " Verify that specialKeys test, still works after the previous junk
1004+ call appendbufline (cmdbufnr, ' $' , ' specialKeys_Test' )
1005+ call WaitFor (' len(ReadXnetbeans()) >= (g:last + 1)' )
1006+ call WaitForAssert ({- > assert_match (' ^send: 0:specialKeys!91 "F12 F13 C-F13"$' ,
1007+ \ ReadXnetbeans ()[-1 ])})
1008+ let g: last += 1
1009+
1010+ sleep 10 m
1011+ endfunc
1012+
9611013" This test used to reference a buffer after it was freed leading to an ASAN
9621014" error.
9631015func Test_nb_bwipe_buffer ()
@@ -967,4 +1019,9 @@ func Test_nb_bwipe_buffer()
9671019 nbclose
9681020endfunc
9691021
1022+ " Verify that the specialKeys argument does not overflow
1023+ func Test_nb_specialKeys_overflow ()
1024+ call s: run_server (' Nb_specialKeys_overflow' )
1025+ endfunc
1026+
9701027" vim: shiftwidth = 2 sts = 2 expandtab
0 commit comments