Commit Diff


commit - a37db869c008253fb19c17cc766ca0dac0e04603
commit + a7f506998d573165fb10a8552b2f48c72094001d
blob - 111605aa74fbad3f7f76de8cb2f3c8f656763ca2
blob + 57c7cf5799deedb39badae981a99eb5d96130329
--- tog/tog.c
+++ tog/tog.c
@@ -113,17 +113,21 @@ mbs2ws(wchar_t **ws, size_t *wlen, const char *s)
 		if (err)
 			return err;
 		*wlen = mbstowcs(NULL, vis, 0);
-		if (*wlen == (size_t)-1)
-			return got_error_from_errno(); /* give up */
+		if (*wlen == (size_t)-1) {
+			err = got_error_from_errno(); /* give up */
+			goto done;
+		}
 	}
 
 	*ws = calloc(*wlen + 1, sizeof(*ws));
-	if (*ws == NULL)
-		return got_error_from_errno();
+	if (*ws == NULL) {
+		err = got_error_from_errno();
+		goto done;
+	}
 
 	if (mbstowcs(*ws, vis ? vis : s, *wlen) != *wlen)
 		err = got_error_from_errno();
-
+done:
 	free(vis);
 	if (err) {
 		free(*ws);