Index: uspace/lib/posix/stdio/scanf.c
===================================================================
--- uspace/lib/posix/stdio/scanf.c	(revision 12fb84980699808e2aeec4cea7dc7753841460b7)
+++ uspace/lib/posix/stdio/scanf.c	(revision cfbb5d180b3f2fdb62c3fb1d77b5aa60ff25dce2)
@@ -303,6 +303,8 @@
 	self->fetched = 0;
 	self->cursor = NULL;
-	free(self->window);
-	self->window = NULL;
+	if (self->window) {
+		free(self->window);
+		self->window = NULL;
+	}
 	self->window_size = 0;
 	self->state = _PROV_CONSTRUCTED;
@@ -653,5 +655,5 @@
 				/* Update the cursor so it can be returned to the provider. */
 				cur_borrowed += cur_updated - cur_limited;
-				if (width != -1) {
+				if (width != -1 && cur_limited != NULL) {
 					/* Deallocate duplicated part of the cursor view. */
 					free(cur_limited);
@@ -833,5 +835,5 @@
 				/* Update the cursor so it can be returned to the provider. */
 				cur_borrowed += cur_updated - cur_limited;
-				if (width != -1) {
+				if (width != -1 && cur_limited != NULL) {
 					/* Deallocate duplicated part of the cursor view. */
 					free(cur_limited);
