Skip to content
This repository
Browse code

"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
Alvaro Lopez Ortega authored May 21, 2011

Showing 1 changed file with 10 additions and 5 deletions. Show diff stats Hide diff stats

  1. 15  cget/main.c
15  cget/main.c
@@ -376,14 +376,19 @@ main (int argc, char **argv)
376 376
 			return EXIT_OK;
377 377
 
378 378
 		case 'O':
379  
-			if (! strncmp (optarg, "-", 1)) {
  379
+			if (global_fd != UNSET_FD) {
  380
+				close (global_fd);
  381
+			}
  382
+
  383
+			if ((strlen(optarg) == 1) && (optarg[0] == '-')) {
380 384
 				global_fd = fileno(stdout);
381 385
 			} else {
382 386
 				global_fd = open (optarg, O_WRONLY | O_CREAT, 0644);
383  
-				if (global_fd < 0) {
384  
-					PRINT_MSG ("ERROR: Can not open %s\n", optarg);
385  
-					return EXIT_ERROR;
386  
-				}
  387
+			}
  388
+
  389
+			if (global_fd < 0) {
  390
+				PRINT_MSG ("ERROR: Can not open %s\n", optarg);
  391
+				return EXIT_ERROR;
387 392
 			}
388 393
 			break;
389 394
 

0 notes on commit 47b1d93

Please sign in to comment.
Something went wrong with that request. Please try again.