Blame SOURCES/0002-virt-top-fix-to-parse-init-file-correctly.patch

62458e
From 1d04fdfce6edea685596fbb18920799c70f1d7fa Mon Sep 17 00:00:00 2001
62458e
From: Yuya Higashi <higashi.yuya@fujitsu.com>
62458e
Date: Mon, 26 Dec 2022 09:18:15 +0900
62458e
Subject: [PATCH 2/2] virt-top: fix to parse init-file correctly
62458e
62458e
This fixes the following runtime error when parsing init-file.
62458e
62458e
$ virt-top --init-file <(echo "sort id")
62458e
Error: Invalid_argument("String.sub / Bytes.sub")
62458e
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
62458e
Called from Stdlib__String.sub in file "string.ml" (inlined), line 50, characters 2-23
62458e
Called from Utils.split in file "utils.ml", line 82, characters 24-68
62458e
Called from Utils.read_config_file.(fun) in file "utils.ml", line 114, characters 23-37
62458e
Called from Stdlib__List.map in file "list.ml", line 92, characters 20-23
62458e
Called from Top.start_up.try_to_read_init_file in file "top.ml", line 153, characters 17-42
62458e
Called from Main.script_mode in file "main.ml", line 37, characters 6-17
62458e
62458e
Signed-off-by: Yuya Higashi <higashi.yuya@fujitsu.com>
62458e
---
62458e
 src/utils.ml | 2 +-
62458e
 1 file changed, 1 insertion(+), 1 deletion(-)
62458e
62458e
diff --git a/src/utils.ml b/src/utils.ml
62458e
index 1f00803..8dfb255 100644
62458e
--- a/src/utils.ml
62458e
+++ b/src/utils.ml
62458e
@@ -79,7 +79,7 @@ let trim ?(test = isspace) str =
62458e
 let split str sep =
62458e
   try
62458e
     let i = String.index str sep in
62458e
-    String.sub str 0 i, String.sub str (i+1) (String.length str - 1)
62458e
+    String.sub str 0 i, String.sub str (i+1) (String.length str - i - 1)
62458e
   with
62458e
     Not_found -> str, ""
62458e
 
62458e
-- 
62458e
2.31.1
62458e