<commit_before>#include "gdb.h"

typedef struct _Backtrace
{
   Module_Gdb *gdb;

   Eina_Array *lines;
   Eina_Bool report;
   char *coredump,
        *jid;

   struct
   {
      Ecore_Event_Handler *data,
                          *del,
                          *error;
   } ev;
} Backtrace;

void
_backtrace_free(Backtrace *b)
{
   char *s;
   Eina_Array_Iterator it;
   unsigned int i;

   ecore_event_handler_del(b->ev.data);
   ecore_event_handler_del(b->ev.del);
   ecore_event_handler_del(b->ev.error);

   free(b->coredump);
   free(b->jid);

   EINA_ARRAY_ITER_NEXT(b->lines, i, s, it)
     free(s);

   free(b);
}

Eina_Bool
_backtrace_data(void *data,
                int type EINA_UNUSED,
                void *event)
{
   Backtrace *b = data;
   Ecore_Exe_Event_Data *d = (Ecore_Exe_Event_Data *)event;
   unsigned int i;

   if (b != ecore_exe_data_get(d->exe))
     return EINA_TRUE;

   DBG("b[%p]", b);

   for (i = 0; d->lines[i].line; i++)
     {
        eina_array_push(b->lines, strdup(d->lines[i].line));
     }
   return EINA_TRUE;
}
<commit_msg>module_gdb: Check that there is lines to read before trying to read them.<commit_after>#include "gdb.h"

typedef struct _Backtrace
{
   Module_Gdb *gdb;

   Eina_Array *lines;
   Eina_Bool report;
   char *coredump,
        *jid;

   struct
   {
      Ecore_Event_Handler *data,
                          *del,
                          *error;
   } ev;
} Backtrace;

void
_backtrace_free(Backtrace *b)
{
   char *s;
   Eina_Array_Iterator it;
   unsigned int i;

   ecore_event_handler_del(b->ev.data);
   ecore_event_handler_del(b->ev.del);
   ecore_event_handler_del(b->ev.error);

   free(b->coredump);
   free(b->jid);

   EINA_ARRAY_ITER_NEXT(b->lines, i, s, it)
     free(s);

   free(b);
}

Eina_Bool
_backtrace_data(void *data,
                int type EINA_UNUSED,
                void *event)
{
   Backtrace *b = data;
   Ecore_Exe_Event_Data *d = (Ecore_Exe_Event_Data *)event;
   unsigned int i;

   if (b != ecore_exe_data_get(d->exe))
     return EINA_TRUE;

   DBG("b[%p]", b);

   if (!d->lines) return EINA_TRUE;

   for (i = 0; d->lines[i].line; i++)
     {
        eina_array_push(b->lines, strdup(d->lines[i].line));
     }
   return EINA_TRUE;
}

{'fraction_non_alphanumeric': 0.13041536400178652, 'fraction_numerical': 0.0008932559178204555, 'mean_word_length': 2.4198473282442747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4483578', 'n_tokens_mistral': 915, 'n_tokens_neox': 876, 'n_words': 168}