Fix warning: ops.c: read_viminfo_register(): Dereference of null pointer: RI.

Problem    : Array access (via field 'y_array') results in a null pointer
             dereference @ 4487.
Diagnostic : Real issue.
Rationale  : If the array was previously freed and the size of the array
             (y_current->y_size) was not updated to zero, the loop @4486
             could be entered and a NULL pointer would be dereferenced.
Resolution : Use free_yank_all() to take care of the NULL check and
             to free the current yank register.
This commit is contained in:
oni-link 2014-12-15 20:06:54 +01:00
parent c63b736921
commit bf4b85a5d4

View File

@ -4483,10 +4483,7 @@ int read_viminfo_register(vir_T *virp, int force)
if (set_prev) if (set_prev)
y_previous = y_current; y_previous = y_current;
for (int i = 0; i < y_current->y_size; i++) { free_yank_all();
free(y_current->y_array[i]);
}
free(y_current->y_array);
array = xmalloc(limit * sizeof(char_u *)); array = xmalloc(limit * sizeof(char_u *));
str = skipwhite(skiptowhite(str)); str = skipwhite(skiptowhite(str));
@ -4515,7 +4512,6 @@ int read_viminfo_register(vir_T *virp, int force)
if (do_it) { if (do_it) {
if (size == 0) { if (size == 0) {
free(array); free(array);
y_current->y_array = NULL;
} else if (size < limit) { } else if (size < limit) {
y_current->y_array = xrealloc(array, size * sizeof(char_u *)); y_current->y_array = xrealloc(array, size * sizeof(char_u *));
} else { } else {