mirror of
https://github.com/vim/vim.git
synced 2025-12-13 20:36:39 +01:00
patch 9.1.1975: blob2str() may call STRNCPY() with a NULL pointer
Problem: blob2str() may call strcpy with a NULL pointer Solution: Check for NULL before calling STRNCPY() closes: #18907 Signed-off-by: Foxe Chen <chen.foxe@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
353103e59a
commit
3d06113c8c
@@ -1242,6 +1242,7 @@ string_from_blob(blob_T *blob, long *start_idx)
|
||||
garray_T str_ga;
|
||||
long blen;
|
||||
int idx;
|
||||
char_u *ret_str = NULL;
|
||||
|
||||
ga_init2(&str_ga, sizeof(char), 80);
|
||||
|
||||
@@ -1262,7 +1263,8 @@ string_from_blob(blob_T *blob, long *start_idx)
|
||||
ga_append(&str_ga, byte);
|
||||
}
|
||||
|
||||
char_u *ret_str = vim_strnsave(str_ga.ga_data, str_ga.ga_len);
|
||||
if (str_ga.ga_data != NULL)
|
||||
ret_str = vim_strnsave(str_ga.ga_data, str_ga.ga_len);
|
||||
*start_idx = idx;
|
||||
|
||||
ga_clear(&str_ga);
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1975,
|
||||
/**/
|
||||
1974,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user