Plan 9 from Bell Labs’s /n/sources/patch/applied/pagefree/readme

Copyright © 2009 Alcatel-Lucent.
Distributed under the Lucent Public License version 1.02.
Download the Plan 9 distribution.


I came across the following code in /sys/src/cmd/page/view.c:

srvfd = open(srv, ORDWR);
free(srv);
if(srvfd == -1){
	fprint(2, "page: can't open %s: %r\n", srv);
	wexits("no srv");
}

Notice that srv is used after being freed when open(2) fails.

This patch simply moves the call to free(2) after the if statement.  Wexits kills the program so no memory should be leaked by that branch.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2009 Alcatel-Lucent. All Rights Reserved.
Comments to webmaster@plan9.bell-labs.com.