(maildir_message_lookup): Fixed bug
(rc could have been used uninitialized). Thanks Wojciech for noticing (maildir_scan0): Fixed typo in notification loop.
Showing
1 changed file
with
6 additions
and
10 deletions
... | @@ -427,10 +427,7 @@ maildir_flush (struct _amd_data *amd) | ... | @@ -427,10 +427,7 @@ maildir_flush (struct _amd_data *amd) |
427 | int rc; | 427 | int rc; |
428 | DIR *dir; | 428 | DIR *dir; |
429 | struct dirent *entry; | 429 | struct dirent *entry; |
430 | char *tmpname = malloc (strlen (amd->name) + sizeof TMPSUF); | 430 | char *tmpname = maildir_mkfilename (amd->name, TMPSUF, NULL); |
431 | |||
432 | strcpy (tmpname, amd->name); | ||
433 | strcat (tmpname, TMPSUF); | ||
434 | 431 | ||
435 | rc = maildir_opendir (&dir, tmpname, PERMS); | 432 | rc = maildir_opendir (&dir, tmpname, PERMS); |
436 | if (rc) | 433 | if (rc) |
... | @@ -489,19 +486,18 @@ maildir_message_lookup (struct _amd_data *amd, char *file_name) | ... | @@ -489,19 +486,18 @@ maildir_message_lookup (struct _amd_data *amd, char *file_name) |
489 | struct _maildir_message *msg; | 486 | struct _maildir_message *msg; |
490 | char *p = strchr (file_name, ':'); | 487 | char *p = strchr (file_name, ':'); |
491 | size_t length = p ? p - file_name : strlen (file_name); | 488 | size_t length = p ? p - file_name : strlen (file_name); |
492 | int rc; | ||
493 | size_t i; | 489 | size_t i; |
494 | 490 | ||
495 | /*FIXME!*/ | 491 | /*FIXME: Replace linear search with binary one! */ |
496 | for (i = 0; i < amd->msg_count; i++) | 492 | for (i = 0; i < amd->msg_count; i++) |
497 | { | 493 | { |
498 | msg = (struct _maildir_message *) amd->msg_array[i]; | 494 | msg = (struct _maildir_message *) amd->msg_array[i]; |
499 | 495 | ||
500 | if (strlen (msg->file_name) <= length | 496 | if (strlen (msg->file_name) <= length |
501 | && (rc = memcmp (msg->file_name, file_name, length)) == 0) | 497 | && memcmp (msg->file_name, file_name, length) == 0) |
502 | break; | 498 | return msg; |
503 | } | 499 | } |
504 | return rc == 0 ? msg : NULL; | 500 | return NULL; |
505 | } | 501 | } |
506 | 502 | ||
507 | static int | 503 | static int |
... | @@ -594,7 +590,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, | ... | @@ -594,7 +590,7 @@ maildir_scan0 (mailbox_t mailbox, size_t msgno ARG_UNUSED, size_t *pcount, |
594 | if (do_notify) | 590 | if (do_notify) |
595 | { | 591 | { |
596 | size_t i; | 592 | size_t i; |
597 | for (i = 0; i < amd->msg_count++; i++) | 593 | for (i = 0; i < amd->msg_count; i++) |
598 | { | 594 | { |
599 | DISPATCH_ADD_MSG(mailbox, amd); | 595 | DISPATCH_ADD_MSG(mailbox, amd); |
600 | } | 596 | } | ... | ... |
-
Please register or sign in to post a comment