summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-15 01:16:49 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-02-15 10:21:14 +0000
commiteb2ead11b5b1852569b34f78ad0a91096dfc7f0a (patch)
treea8ff753c90036d782fded3cc8f8befb120c08a7b
parent8e98c7eef9cdc6b337841fdd11d5b2c8a3079067 (diff)
fix args handling in cmdline class to not be broken
first use consistent ownership (stringshare the strings) and then also properly dup and pass them and not free null arrays and so on where they are used
-rw-r--r--src/lib/ecore/efl_core_command_line.c11
-rw-r--r--src/lib/ecore/efl_thread.c27
2 files changed, 24 insertions, 14 deletions
diff --git a/src/lib/ecore/efl_core_command_line.c b/src/lib/ecore/efl_core_command_line.c
index bd6d21f2d4..424dd3486a 100644
--- a/src/lib/ecore/efl_core_command_line.c
+++ b/src/lib/ecore/efl_core_command_line.c
@@ -180,13 +180,13 @@ _escape(const char *s)
180 return s2; 180 return s2;
181} 181}
182 182
183EOLIAN static const char* 183EOLIAN static const char *
184_efl_core_command_line_command_get(const Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd) 184_efl_core_command_line_command_get(const Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd)
185{ 185{
186 return eina_strdup(pd->string_command); 186 return pd->string_command;
187} 187}
188 188
189EOLIAN static Eina_Accessor* 189EOLIAN static Eina_Accessor *
190_efl_core_command_line_command_access(Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd) 190_efl_core_command_line_command_access(Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd)
191{ 191{
192 return pd->command ? eina_array_accessor_new(pd->command) : NULL; 192 return pd->command ? eina_array_accessor_new(pd->command) : NULL;
@@ -224,7 +224,10 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L
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) 226 for (;i < (array ? eina_array_count(array) : 0); ++i)
227 eina_stringshare_del(content); 227 {
228 content = eina_array_data_get(array, i);
229 eina_stringshare_del(content);
230 }
228 eina_array_free(array); 231 eina_array_free(array);
229 return EINA_FALSE; 232 return EINA_FALSE;
230 } 233 }
diff --git a/src/lib/ecore/efl_thread.c b/src/lib/ecore/efl_thread.c
index 421c92dba7..7e52d7b637 100644
--- a/src/lib/ecore/efl_thread.c
+++ b/src/lib/ecore/efl_thread.c
@@ -153,19 +153,26 @@ _efl_loop_arguments_send(Eo *obj, void *data EINA_UNUSED, const Eina_Value v)
153 int i = 0; 153 int i = 0;
154 154
155 accessor = efl_core_command_line_command_access(obj); 155 accessor = efl_core_command_line_command_access(obj);
156 arga = eina_array_new(10); 156 if (accessor)
157
158 EINA_ACCESSOR_FOREACH(accessor, i, argv)
159 { 157 {
160 eina_array_push(arga, eina_stringshare_add(argv)); 158 arga = eina_array_new(10);
159
160 EINA_ACCESSOR_FOREACH(accessor, i, argv)
161 {
162 eina_array_push(arga, eina_stringshare_add(argv));
163 }
164 arge.argv = arga;
161 } 165 }
162 arge.argv = arga; 166 else arge.argv = NULL;
163 arge.initialization = EINA_TRUE; 167 arge.initialization = EINA_TRUE;
164 efl_event_callback_call(obj, 168 efl_event_callback_call(obj,
165 EFL_LOOP_EVENT_ARGUMENTS, &arge); 169 EFL_LOOP_EVENT_ARGUMENTS, &arge);
166 170 if (accessor)
167 while ((s = eina_array_pop(arga))) eina_stringshare_del(s); 171 {
168 eina_array_free(arga); 172 while ((s = eina_array_pop(arga))) eina_stringshare_del(s);
173 eina_array_free(arga);
174 eina_accessor_free(accessor);
175 }
169 176
170 return v; 177 return v;
171} 178}
@@ -276,7 +283,7 @@ _efl_thread_main(void *data, Eina_Thread t)
276 efl_event_callback_priority_add(obj, it->desc, it->priority, 283 efl_event_callback_priority_add(obj, it->desc, it->priority,
277 it->func, it->user_data); 284 it->func, it->user_data);
278 } 285 }
279 efl_core_command_line_command_array_set(obj, thdat->argv); 286 if (thdat->argv) efl_core_command_line_command_array_set(obj, thdat->argv);
280 thdat->argv = NULL; 287 thdat->argv = NULL;
281 efl_future_then(obj, efl_loop_job(obj), 288 efl_future_then(obj, efl_loop_job(obj),
282 .success = _efl_loop_arguments_send); 289 .success = _efl_loop_arguments_send);
@@ -728,7 +735,7 @@ _efl_thread_efl_task_run(Eo *obj, Efl_Thread_Data *pd)
728 acc = efl_core_command_line_command_access(obj); 735 acc = efl_core_command_line_command_access(obj);
729 if (acc) 736 if (acc)
730 { 737 {
731 thdat->argv = eina_array_new(0); 738 thdat->argv = eina_array_new(1);
732 EINA_ACCESSOR_FOREACH(acc, i, argv) 739 EINA_ACCESSOR_FOREACH(acc, i, argv)
733 { 740 {
734 eina_array_push(thdat->argv, eina_stringshare_add(argv)); 741 eina_array_push(thdat->argv, eina_stringshare_add(argv));