Control: retitle -1 sloccount: php_count, ml_count, c_count: $count /ENOENT & echo /ENOENT | $count -f - &c. segfault Control: merge -1 716181
$ echo /ENOENT | ./ml_count -f - Segmentation fault (core dumped) $ echo /ENOENT | ./c_count -f - Segmentation fault (core dumped) $ echo /ENOENT | ./php_count -f - Segmentation fault (core dumped) $ gdb ../../ml_count core Reading symbols from ../../ml_count... [New LWP 3667230] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `../../ml_count -f N'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x00007f9244e69ce9 in _IO_getc (fp=0x0) at ./libio/getc.c:37 37 ./libio/getc.c: No such file or directory. (gdb) bt #0 0x00007f9244e69ce9 in _IO_getc (fp=0x0) at ./libio/getc.c:37 #1 0x000055b865028265 in getachar (stream=0x0) at ml_count.c:65 #2 0x000055b8650282e6 in sloc_count (filename=0x55b889bd0490 'A' <repeats 24 times>, stream=0x0) at ml_count.c:84 #3 0x000055b8650284c8 in count_file (filename=0x55b889bd0490 'A' <repeats 24 times>) at ml_count.c:150 #4 0x000055b8650286c5 in main (argc=3, argv=0x7fff37503b38) at ml_count.c:198 (gdb) up #1 0x000055b865028265 in getachar (stream=0x0) at ml_count.c:65 65 c = getc(stream); if (argc <= 1) { sloc = sloc_count("-", stdin); printf("%ld %s\n", sloc, "-"); total_sloc += sloc; } else if ((argc == 3) && (!strcmp(argv[1], "-f"))) { if (!strcmp (argv[2], "-")) { file_list = stdin; } else { file_list = fopen(argv[2], "r"); } if (file_list) { while ((s = read_a_line(file_list))) { count_file(s); free(s); } } } else { for (i=1; i < argc; i++) { count_file(argv[i]); } } void count_file(char *filename) { long sloc; FILE *stream; stream = fopen(filename, "r"); line_number = 1; sloc = sloc_count(filename, stream); total_sloc += sloc; printf("%ld %s\n", sloc, filename); fclose(stream); } and getachar() reads from stream directly.
signature.asc
Description: PGP signature