comparison src/memline.c @ 26286:2815b25993fb v8.2.3674

patch 8.2.3674: when ml_get_buf() fails it messes up IObuff Commit: https://github.com/vim/vim/commit/96e7a5928e1e7a350cd6c6d0b9376305190046e7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 25 13:52:37 2021 +0000 patch 8.2.3674: when ml_get_buf() fails it messes up IObuff Problem: When ml_get_buf() fails it messes up IObuff. Solution: Return a local pointer. (closes https://github.com/vim/vim/issues/9214)
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Nov 2021 15:00:06 +0100
parents c2d4e40a32a6
children fc859aea8cec
comparison
equal deleted inserted replaced
26285:4bfa37787ac9 26286:2815b25993fb
2604 int will_change) // line will be changed 2604 int will_change) // line will be changed
2605 { 2605 {
2606 bhdr_T *hp; 2606 bhdr_T *hp;
2607 DATA_BL *dp; 2607 DATA_BL *dp;
2608 static int recursive = 0; 2608 static int recursive = 0;
2609 static char_u questions[4];
2609 2610
2610 if (lnum > buf->b_ml.ml_line_count) // invalid line number 2611 if (lnum > buf->b_ml.ml_line_count) // invalid line number
2611 { 2612 {
2612 if (recursive == 0) 2613 if (recursive == 0)
2613 { 2614 {
2616 ++recursive; 2617 ++recursive;
2617 siemsg(_("E315: ml_get: invalid lnum: %ld"), lnum); 2618 siemsg(_("E315: ml_get: invalid lnum: %ld"), lnum);
2618 --recursive; 2619 --recursive;
2619 } 2620 }
2620 errorret: 2621 errorret:
2621 STRCPY(IObuff, "???"); 2622 STRCPY(questions, "???");
2622 buf->b_ml.ml_line_len = 4; 2623 buf->b_ml.ml_line_len = 4;
2623 return IObuff; 2624 return questions;
2624 } 2625 }
2625 if (lnum <= 0) // pretend line 0 is line 1 2626 if (lnum <= 0) // pretend line 0 is line 1
2626 lnum = 1; 2627 lnum = 1;
2627 2628
2628 if (buf->b_ml.ml_mfp == NULL) // there are no lines 2629 if (buf->b_ml.ml_mfp == NULL) // there are no lines