From e18a303d1c17acd30c21162826c554ee770cf35a Mon Sep 17 00:00:00 2001
From: AlexeyAB <alexeyab84@gmail.com>
Date: Sat, 21 Apr 2018 12:19:58 +0000
Subject: [PATCH] Fixed utils.c for short lines.

---
 src/detector.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/detector.c b/src/detector.c
index 407c8be..86f6afc 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -1048,7 +1048,8 @@
     while(1){
         if(filename){
             strncpy(input, filename, 256);
-			if (input[strlen(input) - 1] == 0x0d) input[strlen(input) - 1] = 0;
+			if(strlen(input) > 0)
+				if (input[strlen(input) - 1] == 0x0d) input[strlen(input) - 1] = 0;
         } else {
             printf("Enter Image Path: ");
             fflush(stdout);
@@ -1146,7 +1147,8 @@
     char *cfg = argv[4];
     char *weights = (argc > 5) ? argv[5] : 0;
 	if(weights)
-		if (weights[strlen(weights) - 1] == 0x0d) weights[strlen(weights) - 1] = 0;
+		if(strlen(weights) > 0)
+			if (weights[strlen(weights) - 1] == 0x0d) weights[strlen(weights) - 1] = 0;
     char *filename = (argc > 6) ? argv[6]: 0;
     if(0==strcmp(argv[2], "test")) test_detector(datacfg, cfg, weights, filename, thresh, hier_thresh, dont_show);
     else if(0==strcmp(argv[2], "train")) train_detector(datacfg, cfg, weights, gpus, ngpus, clear, dont_show);
@@ -1160,7 +1162,8 @@
         char *name_list = option_find_str(options, "names", "data/names.list");
         char **names = get_labels(name_list);
 		if(filename)
-			if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
+			if(strlen(filename) > 0)
+				if (filename[strlen(filename) - 1] == 0x0d) filename[strlen(filename) - 1] = 0;
         demo(cfg, weights, thresh, hier_thresh, cam_index, filename, names, classes, frame_skip, prefix, out_filename,
 			http_stream_port, dont_show);
     }

--
Gitblit v1.10.0