summaryrefslogtreecommitdiff
path: root/src/if_cscope.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-01-30 21:47:52 +0100
committerBram Moolenaar <Bram@vim.org>2018-01-30 21:47:52 +0100
commit1274d33493efb6250470a37b9f4432bb31e87d64 (patch)
tree7f22ff628adc2fc4d13c27bdc604b354b86df39d /src/if_cscope.c
parent0479e910c423d71e2b96bc721feffad5808e767a (diff)
downloadvim-git-1274d33493efb6250470a37b9f4432bb31e87d64.tar.gz
patch 8.0.1439: if cscope fails a search Vim may hangv8.0.1439
Problem: If cscope fails a search Vim may hang. Solution: Bail out when a search error is encountered. (Safouane Baroudi, closes #2598)
Diffstat (limited to 'src/if_cscope.c')
-rw-r--r--src/if_cscope.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/if_cscope.c b/src/if_cscope.c
index 168b3e49e..9466c34f9 100644
--- a/src/if_cscope.c
+++ b/src/if_cscope.c
@@ -677,7 +677,7 @@ cs_cnt_matches(int idx)
{
char *stok;
char *buf;
- int nlines;
+ int nlines = 0;
buf = (char *)alloc(CSREAD_BUFSIZE);
if (buf == NULL)
@@ -700,7 +700,10 @@ cs_cnt_matches(int idx)
* cscope will output error messages before the number-of-lines output.
* Display/discard any output that doesn't match what we want.
* Accept "\S*cscope: X lines", also matches "mlcscope".
+ * Bail out for the "Unable to search" error.
*/
+ if (strstr((const char *)stok, "Unable to search database") != NULL)
+ break;
if ((stok = strtok(buf, (const char *)" ")) == NULL)
continue;
if (strstr((const char *)stok, "cscope:") == NULL)