syscall_filter: Check getline(3) return value.

Bug: None
Test: Unit tests still pass.
Change-Id: I6410c216726c55699967d2218b96ecc30a5d90a0
diff --git a/syscall_filter.c b/syscall_filter.c
index f90878a..9dd7fb2 100644
--- a/syscall_filter.c
+++ b/syscall_filter.c
@@ -3,6 +3,7 @@
  * found in the LICENSE file.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -647,6 +648,14 @@
 		}
 		/* Reuse |line| in the next getline() call. */
 	}
+	/* getline(3) returned -1. This can mean EOF or the below errors. */
+	if (errno == EINVAL || errno == ENOMEM) {
+		if (*arg_blocks) {
+			free_block_list(*arg_blocks);
+			*arg_blocks = NULL;
+		}
+		ret = -1;
+	}
 
 free_line:
 	free(line);