Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

"Resource acquired to 'global_fd' at line 388 may be lost here. Also

there is one similar error on line 388." (klocwork.com Issue #2). --
It also improves how the '-' parameter is parsed.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6648 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit 47b1d9331978fc94ff15c1ac203a52b35f86304c 1 parent 0fcdce9
@alobbs alobbs authored
Showing with 10 additions and 5 deletions.
  1. +10 −5 cget/main.c
View
15 cget/main.c
@@ -376,14 +376,19 @@ main (int argc, char **argv)
return EXIT_OK;
case 'O':
- if (! strncmp (optarg, "-", 1)) {
+ if (global_fd != UNSET_FD) {
+ close (global_fd);
+ }
+
+ if ((strlen(optarg) == 1) && (optarg[0] == '-')) {
global_fd = fileno(stdout);
} else {
global_fd = open (optarg, O_WRONLY | O_CREAT, 0644);
- if (global_fd < 0) {
- PRINT_MSG ("ERROR: Can not open %s\n", optarg);
- return EXIT_ERROR;
- }
+ }
+
+ if (global_fd < 0) {
+ PRINT_MSG ("ERROR: Can not open %s\n", optarg);
+ return EXIT_ERROR;
}
break;
Please sign in to comment.
Something went wrong with that request. Please try again.