Index: uspace/lib/posix/fnmatch.c
===================================================================
--- uspace/lib/posix/fnmatch.c	(revision 94f8b81cc0d9e323b41f8e3b2c969703036cb588)
+++ uspace/lib/posix/fnmatch.c	(revision a12f7f1173cfe373bf0d8758623cfba00364dd2c)
@@ -553,6 +553,10 @@
 
 	if ((flags & FNM_CASEFOLD) != 0) {
-		free((char *) pattern);
-		free((char *) string);
+		if (pattern) {
+			free((char *) pattern);
+		}
+		if (string) {
+			free((char *) string);
+		}
 	}
 
Index: uspace/lib/posix/locale.c
===================================================================
--- uspace/lib/posix/locale.c	(revision 94f8b81cc0d9e323b41f8e3b2c969703036cb588)
+++ uspace/lib/posix/locale.c	(revision a12f7f1173cfe373bf0d8758623cfba00364dd2c)
@@ -127,5 +127,7 @@
 void posix_freelocale(posix_locale_t locobj)
 {
-	free(locobj);
+	if (locobj) {
+		free(locobj);
+	}
 }
 
Index: uspace/lib/posix/stdio/scanf.c
===================================================================
--- uspace/lib/posix/stdio/scanf.c	(revision 94f8b81cc0d9e323b41f8e3b2c969703036cb588)
+++ uspace/lib/posix/stdio/scanf.c	(revision a12f7f1173cfe373bf0d8758623cfba00364dd2c)
@@ -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);
Index: uspace/lib/posix/time.c
===================================================================
--- uspace/lib/posix/time.c	(revision 94f8b81cc0d9e323b41f8e3b2c969703036cb588)
+++ uspace/lib/posix/time.c	(revision a12f7f1173cfe373bf0d8758623cfba00364dd2c)
@@ -968,7 +968,7 @@
 	if (task_stats) {
 		total_cycles = (posix_clock_t) (task_stats->kcycles + task_stats->ucycles);
-	}
-	free(task_stats);
-	task_stats = 0;
+		free(task_stats);
+		task_stats = 0;
+	}
 
 	return total_cycles;
