diff src/option.c @ 16429:a1229400434a v8.1.1219

patch 8.1.1219: not checking for NULL return from alloc() commit https://github.com/vim/vim/commit/6ee9658774942f7448af700fc04df0335796a3db Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 27 22:06:37 2019 +0200 patch 8.1.1219: not checking for NULL return from alloc() Problem: Not checking for NULL return from alloc(). Solution: Add checks. (Martin Kunev, closes https://github.com/vim/vim/issues/4303, closes https://github.com/vim/vim/issues/4174)
author Bram Moolenaar <Bram@vim.org>
date Sat, 27 Apr 2019 22:15:05 +0200
parents 1a4da6903913
children 54ffc82f38a8
line wrap: on
line diff
--- a/src/option.c
+++ b/src/option.c
@@ -13011,13 +13011,12 @@ tabstop_copy(int *oldts)
     int		*newts;
     int		t;
 
-    if (oldts == 0)
-	return 0;
-
-    newts = (int *) alloc((unsigned) ((oldts[0] + 1) * sizeof(int)));
-    for (t = 0; t <= oldts[0]; ++t)
-	newts[t] = oldts[t];
-
+    if (oldts == NULL)
+	return NULL;
+    newts = (int *)alloc((unsigned)((oldts[0] + 1) * sizeof(int)));
+    if (newts != NULL)
+	for (t = 0; t <= oldts[0]; ++t)
+	    newts[t] = oldts[t];
     return newts;
 }
 #endif