...
|
...
|
@@ -505,17 +505,14 @@ static const char *de_packer_2[] = {"p","a","c","k","e","d"};
|
505
|
505
|
|
506
|
506
|
static inline char *textbuffer_done(yyscan_t scanner)
|
507
|
507
|
{
|
508
|
|
- char *str = 0;
|
509
|
|
- /* free unusued memory */
|
510
|
|
- if (!scanner->buf.pos)
|
511
|
|
- scanner->buf.pos++;
|
512
|
|
- str = cli_realloc(scanner->buf.data, scanner->buf.pos);
|
513
|
|
- if(!str)
|
514
|
|
- str = scanner->buf.data;
|
515
|
|
-/* memset(&scanner->buf, 0, sizeof(scanner->buf));
|
516
|
|
- scanner->yytext = str;
|
517
|
|
- scanner->yylen = scanner->buf.pos ? scanner->buf.pos - 1 : 0;*/
|
518
|
|
- return str;
|
|
508
|
+ char *str = cli_realloc(scanner->buf.data, scanner->buf.pos);
|
|
509
|
+ if(!str) {
|
|
510
|
+ str = scanner->buf.data;
|
|
511
|
+ }
|
|
512
|
+ scanner->yytext = str;
|
|
513
|
+ scanner->yylen = scanner->buf.pos - 1;
|
|
514
|
+ memset(&scanner->buf, 0, sizeof(scanner->buf));
|
|
515
|
+ return str;
|
519
|
516
|
}
|
520
|
517
|
|
521
|
518
|
#define MODULE "JS-Norm: "
|
...
|
...
|
@@ -538,7 +535,7 @@ static int replace_token_range(struct tokens *dst, size_t start, size_t end, con
|
538
|
538
|
for(i=start;i<end;i++) {
|
539
|
539
|
free_token(&dst->data[i]);
|
540
|
540
|
}
|
541
|
|
- if(tokens_ensure_capacity(dst, dst->cnt - (end-start) + len) < 0)
|
|
541
|
+ if(tokens_ensure_capacity(dst, dst->cnt - (end-start) + len))
|
542
|
542
|
return CL_EMEM;
|
543
|
543
|
memmove(&dst->data[start+len], &dst->data[end], (dst->cnt - end) * sizeof(dst->data[0]));
|
544
|
544
|
if(with && len > 0) {
|
...
|
...
|
@@ -552,7 +549,7 @@ static int append_tokens(struct tokens *dst, const struct tokens *src)
|
552
|
552
|
{
|
553
|
553
|
if(!dst || !src)
|
554
|
554
|
return CL_ENULLARG;
|
555
|
|
- if(tokens_ensure_capacity(dst, dst->cnt + src->cnt) == -1)
|
|
555
|
+ if(tokens_ensure_capacity(dst, dst->cnt + src->cnt))
|
556
|
556
|
return CL_EMEM;
|
557
|
557
|
cli_dbgmsg(MODULE "Appending %lu tokens\n", src->cnt);
|
558
|
558
|
memcpy(&dst->data[dst->cnt], src->data, src->cnt * sizeof(dst->data[0]));
|
...
|
...
|
@@ -1261,7 +1258,7 @@ static const enum char_class id_ctype[256] = {
|
1261
|
1261
|
static void textbuf_clean(struct text_buffer *buf)
|
1262
|
1262
|
{
|
1263
|
1263
|
if(buf->capacity > BUF_KEEP_SIZE) {
|
1264
|
|
- yystype *data= cli_realloc(buf->data, BUF_KEEP_SIZE);
|
|
1264
|
+ char *data= cli_realloc(buf->data, BUF_KEEP_SIZE);
|
1265
|
1265
|
if (data)
|
1266
|
1266
|
buf->data = data;
|
1267
|
1267
|
buf->capacity = BUF_KEEP_SIZE;
|
...
|
...
|
@@ -1349,6 +1346,8 @@ static inline int parseNumber(YYSTYPE *lvalp, yyscan_t scanner)
|
1349
|
1349
|
scanner->pos--;
|
1350
|
1350
|
textbuffer_putc(&scanner->buf, '\0');
|
1351
|
1351
|
scanner->state = Initial;
|
|
1352
|
+ if (!scanner->buf.data)
|
|
1353
|
+ return 0;
|
1352
|
1354
|
if(is_float) {
|
1353
|
1355
|
TOKEN_SET(lvalp, dval, atof(scanner->buf.data));
|
1354
|
1356
|
return TOK_NumericFloat;
|
...
|
...
|
@@ -1453,14 +1452,13 @@ static int yy_scan_bytes(const char *p, size_t len, yyscan_t scanner)
|
1453
|
1453
|
|
1454
|
1454
|
static const char *yyget_text(yyscan_t scanner)
|
1455
|
1455
|
{
|
1456
|
|
- assert(scanner->yytext || scanner->buf.data);
|
1457
|
|
- return scanner->yytext ? scanner->yytext : scanner->buf.data;
|
|
1456
|
+ return scanner->yytext ? scanner->yytext : scanner->buf.data;
|
1458
|
1457
|
}
|
1459
|
1458
|
|
1460
|
1459
|
static int yyget_leng(yyscan_t scanner)
|
1461
|
1460
|
{
|
1462
|
1461
|
/* we have a \0 too */
|
1463
|
|
- return scanner->yylen ? scanner->yylen : (scanner->buf.pos > 0 ? scanner->buf.pos - 1 : 0);
|
|
1462
|
+ return scanner->yylen ? scanner->yylen: (scanner->buf.pos > 0 ? scanner->buf.pos - 1 : 0);
|
1464
|
1463
|
}
|
1465
|
1464
|
|
1466
|
1465
|
static int yylex(YYSTYPE *lvalp, yyscan_t scanner)
|