Index: test_main.c
===================================================================
RCS file: /cvs/public/parrot/test_main.c,v
retrieving revision 1.35
diff -u -r1.35 test_main.c
--- test_main.c	14 Jan 2002 20:03:52 -0000	1.35
+++ test_main.c	15 Jan 2002 19:52:04 -0000
@@ -99,7 +99,9 @@
             argc--;
         }
         else if (argv[1][1] == 'f') {
-            if (strcmp("-", argv[2]) == 0) {
+            if (argv[2] == 0) {
+                internal_exception(PARROT_USAGE_ERROR, "%s: Must specify - or filename after '-f' switch\n", argv[0]);
+            } else if (strcmp("-", argv[2]) == 0) {
                 from_stdin = 1;
             }
             else {
@@ -169,7 +171,6 @@
         if (from_stdin) {
             char *cursor;
             INTVAL read_result;

             program_size = 0;
             
             program_code = (opcode_t*)malloc(program_size + 1024);
@@ -180,10 +181,12 @@
 
             while ((read_result = read(0, cursor, 1024)) > 0) {
                 program_size += read_result;
-                program_code = realloc(program_code, program_size + 1024);
-                if (NULL == program_code) {
-                    fprintf(stderr,
-                            "Could not reallocate buffer to read stdin\n");
+                /* if we got the full 1024 bytes, allocate some more room */
+                if (read_result == 1024) {
+                    program_code = realloc(program_code, program_size + 1024);
+                    if (NULL == program_code) {
+                        fprintf(stderr, "Could not reallocate buffer to read stdin\n");
+                    }
                 }
                 cursor = (char*)program_code + program_size;
             }
