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
This commit is contained in:
Boris Faure 2017-05-17 23:34:06 +02:00
parent 0517be32f4
commit 490a065fb1
1 changed files with 14 additions and 9 deletions

View File

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