shithub: treason

Download patch

ref: db8bb1cf65a89e025244786c70ba5fc76d9e3fc3
parent: f64f8f7ffe3669b8313a796efa9a60946173ea42
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Nov 4 09:07:12 EST 2020

stream: check for nil stream before closing/reading

--- a/stream.c
+++ b/stream.c
@@ -44,7 +44,7 @@
 void
 Sclose(Stream *s)
 {
-	if(s->type < 0)
+	if(s == nil || s->type < 0)
 		return;
 	s->ops.close(s);
 	s->type = -1;
@@ -53,7 +53,7 @@
 int
 Sread(Stream *s, Streamframe *f)
 {
-	if(s->type < 0)
+	if(s == nil || s->type < 0)
 		return -1;
 	return s->ops.read(s, f);
 }