shithub: 9pro

Download patch

ref: e5a07825d118df77dba755703d4f78335366c17f
parent: 961ec70f7759ad28fa7c0bd8493ceb2b2aa4ec99
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Thu Nov 18 12:46:43 EST 2021

9gc: check calloc result

--- a/9gc.c
+++ b/9gc.c
@@ -305,7 +305,10 @@
 
 	if ((f = dial(s)) < 0)
 		return NULL;
-	c = calloc(1, sizeof(*c));
+	if ((c = calloc(1, sizeof(*c))) == NULL) {
+		close(f);
+		return NULL;
+	}
 	c->f = f;
 	c->c.read = ctxread;
 	c->c.begin = ctxbegin;