diff --git a/lib/librumpuser/rumpfiber.c b/lib/librumpuser/rumpfiber.c index 94730f4a9344..ac4105a91faa 100644 --- a/lib/librumpuser/rumpfiber.c +++ b/lib/librumpuser/rumpfiber.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $ */ +/* $NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $ */ /* * Copyright (c) 2007-2013 Antti Kantee. All Rights Reserved. @@ -68,7 +68,7 @@ #include "rumpuser_port.h" #if !defined(lint) -__RCSID("$NetBSD: rumpfiber.c,v 1.5 2014/11/05 01:39:40 pooka Exp $"); +__RCSID("$NetBSD: rumpfiber.c,v 1.6 2014/11/08 21:27:04 justin Exp $"); #endif /* !lint */ #include @@ -199,11 +199,16 @@ create_thread(const char *name, void *cookie, void (*f)(void *), void *data, { struct thread *thread = calloc(1, sizeof(struct thread)); + if (!thread) { + return NULL; + } + if (!stack) { assert(stack_size == 0); stack = mmap(NULL, STACKSIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); if (stack == MAP_FAILED) { + free(thread); return NULL; } stack_size = STACKSIZE;