patch 9.0.1740: segfault when reading invalid viminfo file

Problem: segfault when reading invalid viminfo file
Solution: Check the expected type in the viminfo file

Thanks to @yegappan for the included test.

closes: #12652
closes: #12845

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Pierre Colin <48397990+Pierre-Colin@users.noreply.github.com>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/viminfo.c b/src/viminfo.c
index b772fc8..fbab05e 100644
--- a/src/viminfo.c
+++ b/src/viminfo.c
@@ -1804,6 +1804,11 @@
 	    y_ptr->y_array[i] = vp[i + 6].bv_string;
 	    vp[i + 6].bv_string = NULL;
 	}
+        else if (vp[i + 6].bv_type != BVAL_STRING)
+        {
+            free(y_ptr->y_array);
+            y_ptr->y_array = NULL;
+        }
 	else
 	    y_ptr->y_array[i] = vim_strsave(vp[i + 6].bv_string);
     }