To: vim_dev@googlegroups.com Subject: Patch 7.4.1959 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1959 Problem: Crash when running test_channel.vim on Windows. Solution: Check for NULL pointer result from FormatMessage(). (Christian Brabandt) Files: src/channel.c *** ../vim-7.4.1958/src/channel.c 2016-06-12 21:18:38.195260819 +0200 --- src/channel.c 2016-06-26 17:29:15.480047458 +0200 *************** *** 261,267 **** --- 261,270 ---- char_u *ptr; if (msgbuf) + { LocalFree(msgbuf); + msgbuf = NULL; + } FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | *************** *** 272,292 **** (LPTSTR) &msgbuf, 0, NULL); ! /* chomp \r or \n */ ! for (ptr = (char_u *)msgbuf; *ptr; ptr++) ! switch (*ptr) ! { ! case '\r': ! STRMOVE(ptr, ptr + 1); ! ptr--; ! break; ! case '\n': ! if (*(ptr + 1) == '\0') ! *ptr = '\0'; ! else ! *ptr = ' '; ! break; ! } return msgbuf; } #endif --- 275,296 ---- (LPTSTR) &msgbuf, 0, NULL); ! if (msgbuf != NULL) ! /* chomp \r or \n */ ! for (ptr = (char_u *)msgbuf; *ptr; ptr++) ! switch (*ptr) ! { ! case '\r': ! STRMOVE(ptr, ptr + 1); ! ptr--; ! break; ! case '\n': ! if (*(ptr + 1) == '\0') ! *ptr = '\0'; ! else ! *ptr = ' '; ! break; ! } return msgbuf; } #endif *************** *** 1436,1442 **** } /* ! * Handle buffer "buf" beeing freed, remove it from any channels. */ void channel_buffer_free(buf_T *buf) --- 1440,1446 ---- } /* ! * Handle buffer "buf" being freed, remove it from any channels. */ void channel_buffer_free(buf_T *buf) *************** *** 2194,2200 **** } else if (p_verbose > 2) { ! ch_errors(channel, "Receved unknown command: %s", (char *)cmd); EMSG2("E905: received unknown command: %s", cmd); } } --- 2198,2204 ---- } else if (p_verbose > 2) { ! ch_errors(channel, "Received unknown command: %s", (char *)cmd); EMSG2("E905: received unknown command: %s", cmd); } } *************** *** 3186,3192 **** { more = channel_parse_json(channel, part); ! /* search for messsage "id" */ if (channel_get_json(channel, part, id, rettv) == OK) { chanpart->ch_block_id = 0; --- 3190,3196 ---- { more = channel_parse_json(channel, part); ! /* search for message "id" */ if (channel_get_json(channel, part, id, rettv) == OK) { chanpart->ch_block_id = 0; *************** *** 3426,3432 **** /* * Common for "ch_sendexpr()" and "ch_sendraw()". * Returns the channel if the caller should read the response. ! * Sets "part_read" to the the read fd. * Otherwise returns NULL. */ channel_T * --- 3430,3436 ---- /* * Common for "ch_sendexpr()" and "ch_sendraw()". * Returns the channel if the caller should read the response. ! * Sets "part_read" to the read fd. * Otherwise returns NULL. */ channel_T * *************** *** 4299,4305 **** { /* The link from the channel to the job doesn't count as a reference, * thus don't decrement the refcount of the job. The reference from ! * the job to the channel does count the refrence, decrement it and * NULL the reference. We don't set ch_job_killed, unreferencing the * job doesn't mean it stops running. */ job->jv_channel->ch_job = NULL; --- 4303,4309 ---- { /* The link from the channel to the job doesn't count as a reference, * thus don't decrement the refcount of the job. The reference from ! * the job to the channel does count the reference, decrement it and * NULL the reference. We don't set ch_job_killed, unreferencing the * job doesn't mean it stops running. */ job->jv_channel->ch_job = NULL; *** ../vim-7.4.1958/src/version.c 2016-06-26 17:19:42.362180288 +0200 --- src/version.c 2016-06-26 17:30:00.643248336 +0200 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 1959, /**/ -- "The sun oozed over the horizon, shoved aside darkness, crept along the greensward, and, with sickly fingers, pushed through the castle window, revealing the pillaged princess, hand at throat, crown asunder, gaping in frenzied horror at the sated, sodden amphibian lying beside her, disbelieving the magnitude of the frog's deception, screaming madly, "You lied!" - Winner of the Bulwer-Lytton contest (San Jose State University), wherein one writes only the first line of a bad novel /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///