summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-14 11:28:23 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-15 10:21:04 +0000
commit8e98c7eef9cdc6b337841fdd11d5b2c8a3079067 (patch)
tree80c46ba71236cb10b1cd0c7c79466a2560d1f52a
parent9d65e64c00858f6827ec786737a59c728f440f8b (diff)
cmdline iface - fix to consume input array AND strings totally
strings often enough are generated e.g. via "%s/%s" or "%i" or similar etc. ... i have poitned to examples, so move to make all strings consistently stringshared, fix a bug added to the efl thread code where it accessed and freed array even tho array was consumed (but not strings) in the set, and the code used free to consume not stringshare_del. fix other code and tests to match EXCTLY the kind of bugs and mistakes with this kind of design that i said would happen more often just happened...
-rw-r--r--src/lib/ecore/efl_core_command_line.c3
-rw-r--r--src/lib/ecore/efl_core_command_line.eo2
-rw-r--r--src/lib/ecore/efl_loop.c5
-rw-r--r--src/lib/ecore/efl_thread.c4
-rw-r--r--src/tests/ecore/efl_app_test_cml.c14
5 files changed, 16 insertions, 12 deletions
diff --git a/src/lib/ecore/efl_core_command_line.c b/src/lib/ecore/efl_core_command_line.c
index 24cab90b0e..bd6d21f2d4 100644
--- a/src/lib/ecore/efl_core_command_line.c
+++ b/src/lib/ecore/efl_core_command_line.c
@@ -223,6 +223,8 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L
223 eina_stringshare_del(eina_array_pop(pd->command)); 223 eina_stringshare_del(eina_array_pop(pd->command));
224 eina_array_free(pd->command); 224 eina_array_free(pd->command);
225 pd->command = NULL; 225 pd->command = NULL;
226 for (;i < (array ? eina_array_count(array) : 0); ++i)
227 eina_stringshare_del(content);
226 eina_array_free(array); 228 eina_array_free(array);
227 return EINA_FALSE; 229 return EINA_FALSE;
228 } 230 }
@@ -236,6 +238,7 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L
236 _remove_invalid_chars(param); 238 _remove_invalid_chars(param);
237 eina_array_push(pd->command, eina_stringshare_add(param)); 239 eina_array_push(pd->command, eina_stringshare_add(param));
238 free(param); 240 free(param);
241 eina_stringshare_del(content);
239 } 242 }
240 pd->string_command = eina_strbuf_release(command); 243 pd->string_command = eina_strbuf_release(command);
241 pd->filled = EINA_TRUE; 244 pd->filled = EINA_TRUE;
diff --git a/src/lib/ecore/efl_core_command_line.eo b/src/lib/ecore/efl_core_command_line.eo
index 436720d9bd..25b7c88b6e 100644
--- a/src/lib/ecore/efl_core_command_line.eo
+++ b/src/lib/ecore/efl_core_command_line.eo
@@ -60,7 +60,7 @@ mixin @beta Efl.Core.Command_Line {
60 return : bool; [[On success $true, $false otherwise]] 60 return : bool; [[On success $true, $false otherwise]]
61 } 61 }
62 values { 62 values {
63 array : array<string> @owned; [[An array where every array field is an argument]] 63 array : array<const(stringshare)> @owned; [[An array where every array field is an argument]]
64 } 64 }
65 } 65 }
66 @property command_string { 66 @property command_string {
diff --git a/src/lib/ecore/efl_loop.c b/src/lib/ecore/efl_loop.c
index 342a6f7725..1096c62bdb 100644
--- a/src/lib/ecore/efl_loop.c
+++ b/src/lib/ecore/efl_loop.c
@@ -390,8 +390,11 @@ ecore_loop_arguments_send(int argc, const char **argv)
390 cml = eina_array_new(argc); 390 cml = eina_array_new(argc);
391 for (i = 0; i < argc; i++) 391 for (i = 0; i < argc; i++)
392 { 392 {
393 Eina_Stringshare *arg = eina_stringshare_add(argv[i]); 393 Eina_Stringshare *arg;
394
395 arg = eina_stringshare_add(argv[i]);
394 eina_array_push(arga, arg); 396 eina_array_push(arga, arg);
397 arg = eina_stringshare_add(argv[i]);
395 eina_array_push(cml, arg); 398 eina_array_push(cml, arg);
396 } 399 }
397 400
diff --git a/src/lib/ecore/efl_thread.c b/src/lib/ecore/efl_thread.c
index a324af4f58..421c92dba7 100644
--- a/src/lib/ecore/efl_thread.c
+++ b/src/lib/ecore/efl_thread.c
@@ -277,11 +277,9 @@ _efl_thread_main(void *data, Eina_Thread t)
277 it->func, it->user_data); 277 it->func, it->user_data);
278 } 278 }
279 efl_core_command_line_command_array_set(obj, thdat->argv); 279 efl_core_command_line_command_array_set(obj, thdat->argv);
280 thdat->argv = NULL;
280 efl_future_then(obj, efl_loop_job(obj), 281 efl_future_then(obj, efl_loop_job(obj),
281 .success = _efl_loop_arguments_send); 282 .success = _efl_loop_arguments_send);
282
283 while (thdat->argv && eina_array_count(thdat->argv)) free(eina_array_pop(thdat->argv));
284 eina_array_free(thdat->argv);
285 free(thdat->event_cb); 283 free(thdat->event_cb);
286 thdat->event_cb = NULL; 284 thdat->event_cb = NULL;
287 285
diff --git a/src/tests/ecore/efl_app_test_cml.c b/src/tests/ecore/efl_app_test_cml.c
index 1b7cebf552..33024dabb8 100644
--- a/src/tests/ecore/efl_app_test_cml.c
+++ b/src/tests/ecore/efl_app_test_cml.c
@@ -23,13 +23,13 @@ _construct_array(void)
23{ 23{
24 Eina_Array *array = eina_array_new(16); 24 Eina_Array *array = eina_array_new(16);
25 25
26 eina_array_push(array, "/bin/sh"); 26 eina_array_push(array, eina_stringshare_add("/bin/sh"));
27 eina_array_push(array, "-C"); 27 eina_array_push(array, eina_stringshare_add("-C"));
28 eina_array_push(array, "foo"); 28 eina_array_push(array, eina_stringshare_add("foo"));
29 eina_array_push(array, "--test"); 29 eina_array_push(array, eina_stringshare_add("--test"));
30 eina_array_push(array, "--option=done"); 30 eina_array_push(array, eina_stringshare_add("--option=done"));
31 eina_array_push(array, "--"); 31 eina_array_push(array, eina_stringshare_add("--"));
32 eina_array_push(array, "asdf --test"); 32 eina_array_push(array, eina_stringshare_add("asdf --test"));
33 return array; 33 return array;
34} 34}
35 35