Mercurial > vim
comparison src/netbeans.c @ 9250:d82724272c61 v7.4.1908
commit https://github.com/vim/vim/commit/5ce4a0b96ab688b1ea2481c2516e2889ff6713bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 8 20:17:23 2016 +0200
patch 7.4.1908
Problem: Netbeans uses uninitialzed pointer and freed memory.
Solution: Set "buffer" at the right place (hint by Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 08 Jun 2016 20:30:06 +0200 |
parents | 6ee88fa405b3 |
children | 1f9172cbfef1 |
comparison
equal
deleted
inserted
replaced
9249:1df574290be4 | 9250:d82724272c61 |
---|---|
391 { | 391 { |
392 node = channel_peek(nb_channel, PART_SOCK); | 392 node = channel_peek(nb_channel, PART_SOCK); |
393 if (node == NULL) | 393 if (node == NULL) |
394 break; /* nothing to read */ | 394 break; /* nothing to read */ |
395 | 395 |
396 /* Locate the first line in the first buffer. */ | 396 /* Locate the end of the first line in the first buffer. */ |
397 p = channel_first_nl(node); | 397 p = channel_first_nl(node); |
398 if (p == NULL) | 398 if (p == NULL) |
399 { | 399 { |
400 /* Command isn't complete. If there is no following buffer, | 400 /* Command isn't complete. If there is no following buffer, |
401 * return (wait for more). If there is another buffer following, | 401 * return (wait for more). If there is another buffer following, |
402 * prepend the text to that buffer and delete this one. */ | 402 * prepend the text to that buffer and delete this one. */ |
403 if (channel_collapse(nb_channel, PART_SOCK, TRUE) == FAIL) | 403 if (channel_collapse(nb_channel, PART_SOCK, TRUE) == FAIL) |
404 return; | 404 return; |
405 continue; | |
406 } | |
407 | |
408 /* There is a complete command at the start of the buffer. | |
409 * Terminate it with a NUL. When no more text is following unlink | |
410 * the buffer. Do this before executing, because new buffers can | |
411 * be added while busy handling the command. */ | |
412 *p++ = NUL; | |
413 if (*p == NUL) | |
414 { | |
415 own_node = TRUE; | |
416 buffer = channel_get(nb_channel, PART_SOCK); | |
417 /* "node" is now invalid! */ | |
405 } | 418 } |
406 else | 419 else |
407 { | 420 { |
408 /* There is a complete command at the start of the buffer. | 421 own_node = FALSE; |
409 * Terminate it with a NUL. When no more text is following unlink | 422 buffer = node->rq_buffer; |
410 * the buffer. Do this before executing, because new buffers can | 423 } |
411 * be added while busy handling the command. */ | 424 |
412 *p++ = NUL; | 425 /* now, parse and execute the commands */ |
413 if (*p == NUL) | 426 nb_parse_cmd(buffer); |
414 { | 427 |
415 own_node = TRUE; | 428 if (own_node) |
416 channel_get(nb_channel, PART_SOCK); | 429 /* buffer finished, dispose of it */ |
417 } | 430 vim_free(buffer); |
418 else | 431 else |
419 own_node = FALSE; | 432 /* more follows, move it to the start */ |
420 | 433 channel_consume(nb_channel, PART_SOCK, (int)(p - buffer)); |
421 /* now, parse and execute the commands */ | |
422 nb_parse_cmd(node->rq_buffer); | |
423 | |
424 if (own_node) | |
425 /* buffer finished, dispose of it */ | |
426 vim_free(node->rq_buffer); | |
427 else | |
428 /* more follows, move it to the start */ | |
429 channel_consume(nb_channel, PART_SOCK, (int)(p - buffer)); | |
430 } | |
431 } | 434 } |
432 } | 435 } |
433 | 436 |
434 /* | 437 /* |
435 * Handle one NUL terminated command. | 438 * Handle one NUL terminated command. |