Eliminate a segfault when called on an existing file with out an extension:

touch foo && gunzip foo
This commit is contained in:
Matt Kraai committed 2001-04-18 15:51:45 +00:00
1 parent b181056e06
commit 54652230d4
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -158,9 +158,9 @@ extern int gunzip_main(int argc, char **argv)
delete_old_file = TRUE;
extension = strrchr(if_name, '.');
if (strcmp(extension, ".gz") == 0) {
if (extension && strcmp(extension, ".gz") == 0) {
length -= 3;
} else if (strcmp(extension, ".tgz") == 0) {
} else if (extension && strcmp(extension, ".tgz") == 0) {
length -= 4;
} else {
error_msg_and_die("Invalid extension");
+2 -2
View File
@@ -158,9 +158,9 @@ extern int gunzip_main(int argc, char **argv)
delete_old_file = TRUE;
extension = strrchr(if_name, '.');
if (strcmp(extension, ".gz") == 0) {
if (extension && strcmp(extension, ".gz") == 0) {
length -= 3;
} else if (strcmp(extension, ".tgz") == 0) {
} else if (extension && strcmp(extension, ".tgz") == 0) {
length -= 4;
} else {
error_msg_and_die("Invalid extension");