mirror of
https://github.com/neovim/neovim.git
synced 2026-04-02 05:39:26 +00:00
vim-patch:9.2.0091: missing out-of-memory checks in quickfix.c
Problem: missing out-of-memory checks in quickfix.c
Solution: Improve error handline, refactor qf_push_dir() slightly
(John Marriott).
closes: vim/vim#19528
0155401538
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -2365,9 +2365,10 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
|
|||||||
{
|
{
|
||||||
struct dir_stack_T *ds_ptr;
|
struct dir_stack_T *ds_ptr;
|
||||||
|
|
||||||
// allocate new stack element and hook it in
|
// allocate new stack element
|
||||||
struct dir_stack_T *ds_new = xmalloc(sizeof(struct dir_stack_T));
|
struct dir_stack_T *ds_new = xmalloc(sizeof(struct dir_stack_T));
|
||||||
|
|
||||||
|
// push the new element onto the stack
|
||||||
ds_new->next = *stackptr;
|
ds_new->next = *stackptr;
|
||||||
*stackptr = ds_new;
|
*stackptr = ds_new;
|
||||||
|
|
||||||
@@ -2383,9 +2384,10 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
|
|||||||
ds_new = (*stackptr)->next;
|
ds_new = (*stackptr)->next;
|
||||||
(*stackptr)->dirname = NULL;
|
(*stackptr)->dirname = NULL;
|
||||||
while (ds_new) {
|
while (ds_new) {
|
||||||
xfree((*stackptr)->dirname);
|
char *dirname = concat_fnames(ds_new->dirname, dirbuf, true);
|
||||||
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf, true);
|
if (os_isdir(dirname)) {
|
||||||
if (os_isdir((*stackptr)->dirname)) {
|
xfree((*stackptr)->dirname);
|
||||||
|
(*stackptr)->dirname = dirname;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2410,9 +2412,12 @@ static char *qf_push_dir(char *dirbuf, struct dir_stack_T **stackptr, bool is_fi
|
|||||||
if ((*stackptr)->dirname != NULL) {
|
if ((*stackptr)->dirname != NULL) {
|
||||||
return (*stackptr)->dirname;
|
return (*stackptr)->dirname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pop the new element from the stack and free it
|
||||||
ds_ptr = *stackptr;
|
ds_ptr = *stackptr;
|
||||||
*stackptr = (*stackptr)->next;
|
*stackptr = (*stackptr)->next;
|
||||||
xfree(ds_ptr);
|
xfree(ds_ptr);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user