Fix for binary policy modules.

They do not retain the neverallow source information so we must
not assume that source_filename is set.  Either need a new binary
module format if we want to propagate this information for modular
builds or get rid of binary modules.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Bug: https://code.google.com/p/android/issues/detail?id=73183

(cherry picked from commit d26204e7d0a3be178a97d4920b82007e05a2a632)

Change-Id: I88e220816430b57d5cb366f3a1e0c22fc64fffef
diff --git a/src/expand.c b/src/expand.c
index 947bee0..acb6906 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -2651,9 +2651,11 @@
 	avrule->line = source_rule->line;
 	avrule->flags = source_rule->flags;
 	avrule->source_line = source_rule->source_line;
-	avrule->source_filename = strdup(source_rule->source_filename);
-	if (!avrule->source_filename)
-		goto err;
+	if (source_rule->source_filename) {
+		avrule->source_filename = strdup(source_rule->source_filename);
+		if (!avrule->source_filename)
+			goto err;
+	}
 
 	if (ebitmap_cpy(&avrule->stypes.types, &stypes))
 		goto err;
diff --git a/src/link.c b/src/link.c
index ca497a7..c8c510a 100644
--- a/src/link.c
+++ b/src/link.c
@@ -1326,9 +1326,11 @@
 		}
 		new_rule->line = cur->line;
 		new_rule->source_line = cur->source_line;
-		new_rule->source_filename = strdup(cur->source_filename);
-		if (!new_rule->source_filename)
-			goto cleanup;
+		if (cur->source_filename) {
+			new_rule->source_filename = strdup(cur->source_filename);
+			if (!new_rule->source_filename)
+				goto cleanup;
+		}
 
 		cur = cur->next;