termptyesc: _csi_arg_get() could be called with nothing to read

Could be the case when an error was already found while decoding the
stream
devs/iscaro/meson
Boris Faure 6 years ago
parent 0517be32f4
commit 490a065fb1
  1. 23
      src/bin/termptyesc.c

@ -93,25 +93,30 @@ _csi_arg_get(Eina_Unicode **ptr)
Eina_Unicode *b = *ptr;
int sum = 0;
while ((*b) && (*b < '0' || *b > '9')) b++;
if (!b)
goto error;
while ((*b) && (*b < '0' || *b > '9'))
b++;
if (!*b)
{
*ptr = NULL;
return 0;
}
goto error;
while ((*b >= '0') && (*b <= '9'))
{
if (sum > INT32_MAX/10 )
{
*ptr = NULL;
return 0;
}
goto error;
sum *= 10;
sum += *b - '0';
b++;
}
*ptr = b;
return sum;
error:
*ptr = NULL;
return -1;
}
static void

Loading…
Cancel
Save