diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c
index 802ec9fd9a8b52981e99466b14847fc7f3d9ef8f..74ce9726135dbd0a00d4f9ecfc3e3ebb5eb6651e 100644
--- a/src/conio/bitmap_con.c
+++ b/src/conio/bitmap_con.c
@@ -163,7 +163,7 @@ static int bitmap_loadfont_locked(const char *filename)
 	}
 
 	fh=vstat.charheight;
-	fdw = vstat.charwidth - (vstat.flags & VIDMODES_FLAG_EXPAND) ? 1 : 0;
+	fdw = vstat.charwidth - ((vstat.flags & VIDMODES_FLAG_EXPAND) ? 1 : 0);
 	fw = fdw / 8 + (fdw % 8 ? 1 : 0);
 
 	fontsize=fw*fh*256*sizeof(unsigned char);
@@ -1564,8 +1564,8 @@ void bitmap_replace_font(uint8_t id, char *name, void *data, size_t size)
 			free(name);
 			free(data);
 	}
-	request_redraw();
 	pthread_mutex_unlock(&screenlock);
+	request_redraw();
 }
 
 int bitmap_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b)
diff --git a/src/conio/x_events.c b/src/conio/x_events.c
index 5481a1798114edcf6513dcd411159283e0707975..85a14b5d9f99d2092826acb66b494f2bcd122de4 100644
--- a/src/conio/x_events.c
+++ b/src/conio/x_events.c
@@ -427,7 +427,7 @@ static int init_window()
 	pthread_mutex_lock(&vstatlock);
 	bitmap_get_scaled_win_size(x_cvstat.scaling, &w, &h, mw, mh);
 	vstat.winwidth = x_cvstat.winwidth = w;
-	vstat.winwidth = x_cvstat.winheight = h;
+	vstat.winheight = x_cvstat.winheight = h;
 	vstat.scaling = x_cvstat.scaling;
 	pthread_mutex_unlock(&vstatlock);
 	win = x11.XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0,
diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c
index d50224196f9e8bf503d94fd71fee4e63f890b9ff..abcaca57c4e158c9082cfd30e5603dfe0acd3ee2 100644
--- a/src/syncterm/ripper.c
+++ b/src/syncterm/ripper.c
@@ -9082,9 +9082,9 @@ do_fill(bool overwrite)
 	bool                  in_line = false;
 
 	pix = getpixels(0, 0, rip.x_max - 1, rip.y_max - 1, false);
-	FREE_AND_NULL(pix->pixelsb);
 	if (pix == NULL)
 		return;
+	FREE_AND_NULL(pix->pixelsb);
 
         // Horizontal even-odd top-left to bottom-right.
 	pixel = 0;
diff --git a/src/syncterm/term.c b/src/syncterm/term.c
index 140ee2011451cd01fda2b07c8a9bae9e6f066a68..5abd94123c44fbdfdc8dfc6645e42f67c4e0e2ae 100644
--- a/src/syncterm/term.c
+++ b/src/syncterm/term.c
@@ -1460,9 +1460,10 @@ xmodem_progress(void *cbdata, unsigned block_num, int64_t offset, int64_t fsize,
 		if ((cps = (unsigned)(offset / t)) == 0)
 			cps = 1;           /* cps so far */
 		l = (time_t)(fsize / cps); /* total transfer est time */
-		l -= t;                    /* now, it's est time left */
-		if (l < 0)
+		if (t >= l)
 			l = 0;
+		else
+			l -= t;                    /* now, it's est time left */
 		if ((*(xm->mode)) & SEND) {
 			total_blocks = num_blocks(block_num, offset, fsize, xm->block_size);
 			cprintf("Block (%lu%s): %u/%" PRId64 "  Byte: %" PRId64,
@@ -3211,10 +3212,10 @@ paste_pixmap(char *str, size_t slen, char *fn, void *apcd)
 	}
 
 	if (bufnum >= sizeof(pixmap_buffer) / sizeof(pixmap_buffer[0]))
-		return;
+		goto done;
 
 	if (pixmap_buffer[bufnum] == NULL)
-		return;
+		goto done;
 
 	if (sw == 0)
 		sw = pixmap_buffer[bufnum]->width - sx;
@@ -3242,6 +3243,7 @@ paste_pixmap(char *str, size_t slen, char *fn, void *apcd)
 	if (maskfn != NULL) {
 		freemask(ctmask);
 		ctmask = read_pbm(maskfn, true);
+		free(maskfn);
 		if (ctmask == NULL)
 			goto done;
 	}