shithub: riscv

Download patch

ref: 404c901f299c4d93cb159a3c44c2977a25408319
parent: 81647c202550634b99c2bc93dd055b8d54725abf
author: Alex Musolino <[email protected]>
date: Tue Dec 15 15:45:26 EST 2020

ico: avoid potential nil pointer dereferences

Bgeticon can fail, leaving the Icon img pointers nil.

--- a/sys/src/cmd/jpg/ico.c
+++ b/sys/src/cmd/jpg/ico.c
@@ -535,6 +535,8 @@
 	r.max.x = screen->r.min.x;
 	r.min.y = screen->r.min.y + font->height + 2*BORDER;
 	for(icon = h.first; icon != nil; icon = icon->next){
+		if(icon->img == nil)
+			continue;
 		r.min.x = r.max.x + BORDER;
 		r.max.x = r.min.x + Dx(icon->img->r);
 		r.max.y = r.min.y + Dy(icon->img->r);