Skip to contentSkip to conversation

uml: Handle failed malloc.

PATCH New Jim Meyering 1 participant 1 message Feb 5, 2008 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uml: Handle failed malloc.

* arch/um/os-Linux/mem.c (make_tempfile): Don't deref NULL upon failed malloc.

---

arch/um/os-Linux/mem.c +2 -0
index 436f8d2..e114d09 100644
@@ -172,6 +172,8 @@ int __init make_tempfile(const char *template, char **out_tempname,
 
 	which_tmpdir();
 	tempname = malloc(MAXPATHLEN);
+	if (tempname == NULL)
+	  return -1;
 
 	find_tempdir();
 	if (template[0] != '/')