ref: 3047fe8ab68b8db233cbe02e44b55810bb45a93d
parent: 62d71e551d0bc58c82ff8e06307c6566174dff1c
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Tue Aug 27 19:26:30 EDT 2013
devmouse: fix openmode() handling openmode() can raise error with invalid mode passed, but we already incremented the exclusive mouse refcount at that point! call openmode() early to avoid this.
--- a/sys/src/9/port/devmouse.c
+++ b/sys/src/9/port/devmouse.c
@@ -170,6 +170,9 @@
static Chan*
mouseopen(Chan *c, int omode)
{+ int mode;
+
+ mode = openmode(omode);
switch((ulong)c->qid.path){case Qdir:
if(omode != OREAD)
@@ -193,7 +196,7 @@
default:
incref(&mouse);
}
- c->mode = openmode(omode);
+ c->mode = mode;
c->flag |= COPEN;
c->offset = 0;
return c;
--
⑨