Commit b3198773 b3198773bceed30ff1a068a43b17713433bd8125 by Sergey Poznyakoff

(sieve_tag_lookup): Check for taglist != NULL before calling list_do().

1 parent 0cee560a
...@@ -403,7 +403,7 @@ sieve_tag_lookup (list_t taglist, char *name, sieve_value_t **arg) ...@@ -403,7 +403,7 @@ sieve_tag_lookup (list_t taglist, char *name, sieve_value_t **arg)
403 sieve_runtime_tag_t t; 403 sieve_runtime_tag_t t;
404 404
405 t.tag = name; 405 t.tag = name;
406 if (list_do (taglist, tag_finder, &t)) 406 if (taglist && list_do (taglist, tag_finder, &t))
407 { 407 {
408 if (arg) 408 if (arg)
409 *arg = t.arg; 409 *arg = t.arg;
...@@ -448,20 +448,23 @@ sieve_vlist_do (sieve_value_t *val, list_action_t *ac, void *data) ...@@ -448,20 +448,23 @@ sieve_vlist_do (sieve_value_t *val, list_action_t *ac, void *data)
448 struct comp_data { 448 struct comp_data {
449 sieve_value_t *val; 449 sieve_value_t *val;
450 sieve_comparator_t comp; 450 sieve_comparator_t comp;
451 sieve_relcmp_t test;
451 sieve_retrieve_t retr; 452 sieve_retrieve_t retr;
452 void *data; 453 void *data;
454 size_t count;
453 }; 455 };
454 456
455 struct comp_data2 { 457 struct comp_data2 {
456 char *sample; 458 char *sample;
457 sieve_comparator_t comp; 459 sieve_comparator_t comp;
460 sieve_relcmp_t test;
458 }; 461 };
459 462
460 int 463 int
461 _comp_action2 (void *item, void *data) 464 _comp_action2 (void *item, void *data)
462 { 465 {
463 struct comp_data2 *cp = data; 466 struct comp_data2 *cp = data;
464 return cp->comp (item, cp->sample); 467 return cp->test (cp->comp (item, cp->sample), 0);
465 } 468 }
466 469
467 int 470 int
...@@ -473,9 +476,11 @@ _comp_action (void *item, void *data) ...@@ -473,9 +476,11 @@ _comp_action (void *item, void *data)
473 int i; 476 int i;
474 477
475 d.comp = cp->comp; 478 d.comp = cp->comp;
479 d.test = cp->test;
476 for (i = 0; cp->retr (item, cp->data, i, &d.sample) == 0; i++) 480 for (i = 0; cp->retr (item, cp->data, i, &d.sample) == 0; i++)
477 if (d.sample) 481 if (d.sample)
478 { 482 {
483 cp->count++;
479 rc = sieve_vlist_do (cp->val, _comp_action2, &d); 484 rc = sieve_vlist_do (cp->val, _comp_action2, &d);
480 free (d.sample); 485 free (d.sample);
481 } 486 }
...@@ -484,14 +489,21 @@ _comp_action (void *item, void *data) ...@@ -484,14 +489,21 @@ _comp_action (void *item, void *data)
484 489
485 int 490 int
486 sieve_vlist_compare (sieve_value_t *a, sieve_value_t *b, 491 sieve_vlist_compare (sieve_value_t *a, sieve_value_t *b,
487 sieve_comparator_t comp, sieve_retrieve_t retr, 492 sieve_comparator_t comp, sieve_relcmp_t test,
488 void *data) 493 sieve_retrieve_t retr,
494 void *data, size_t *count)
489 { 495 {
490 struct comp_data d; 496 struct comp_data d;
491 497 int rc;
498
492 d.comp = comp; 499 d.comp = comp;
500 d.test = test;
493 d.retr = retr; 501 d.retr = retr;
494 d.data = data; 502 d.data = data;
495 d.val = b; 503 d.val = b;
496 return sieve_vlist_do (a, _comp_action, &d); 504 d.count = 0;
505 rc = sieve_vlist_do (a, _comp_action, &d);
506 if (count)
507 *count = d.count;
508 return rc;
497 } 509 }
......