Text   |  XML   |  ReML   |   Visible Warnings:

Null Pointer Dereference  at test-lib.c:527

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

test_priorityq

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/tests/test-lib.c)expand/collapse
Show more  
 490  static void test_priorityq(void)
 491  {
 492  #define PQ_MAX_ITEMS 100
 493          static const int input[] = {
 494                  1, 2, 3, 4, 5, 6, 7, 8, -1,
 495                  8, 7, 6, 5, 4, 3, 2, 1, -1,
 496                  8, 7, 5, 6, 1, 3, 4, 2, -1,
 497                  -1
 498          };
 499          static const int output[] = {
 500                  1, 2, 3, 4, 5, 6, 7, 8 
 501          };
 502          struct pq_test_item *item, items[PQ_MAX_ITEMS];
 503          unsigned int i, j;
 504          struct priorityq *pq;
 505          pool_t pool;
 506          int prev;
 507          bool success = TRUE;
 508   
 509          pool = pool_alloconly_create("priorityq items", 1024);
 510   
 511          /* simple tests with popping only */
 512          for (i = 0; input[i] != -1; i++) {
 513                  p_clear(pool);
 514                  pq = priorityq_init(cmp_int, 1);
 515                  for (j = 0; input[i] != -1; i++, j++) {
 516                          if (priorityq_count(pq) != j)
 517                                  success = FALSE;
 518                          item = p_new(pool, struct pq_test_item, 1);
 519                          item->num = input[i];
 520                          priorityq_add(pq, &item->item);
 521                  }
 522                  for (j = 0; j < N_ELEMENTS(output); j++) {
 523                          if (priorityq_count(pq) != N_ELEMENTS(output) - j)
 524                                  success = FALSE;
 525   
 526[+]                         item = (struct pq_test_item *)priorityq_peek(pq);
 527                          if (output[j] != item->num)
 528                                  success = FALSE;
 529                          item = (struct pq_test_item *)priorityq_pop(pq);
 530                          if (output[j] != item->num)
 531                                  success = FALSE;
 532                  }
 533                  if (priorityq_count(pq) != 0)
 534                          success = FALSE;
 535                  if (priorityq_peek(pq) != NULL || priorityq_pop(pq) != NULL)
 536                          success = FALSE;
 537                  priorityq_deinit(&pq);
Show more  




Change Warning 8024.24601 : Null Pointer Dereference

Because they are very similar, this warning shares annotations with warning 8024.24602.

Priority:
State:
Finding:
Owner:
Note: