<<< Date Index >>>     <<< Thread Index >>>

mutt/2515: Sorting by from or to in index is sometimes incorrect



>Number:         2515
>Notify-List:    pywatson@xxxxxxxxx
>Category:       mutt
>Synopsis:       Sorting by from or to in index is sometimes incorrect
>Confidential:   no
>Severity:       minor
>Priority:       low
>Responsible:    mutt-dev
>State:          open
>Keywords:       
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 07 03:49:37 +0200 2006
>Originator:     Pythagoras Watson
>Release:        1.5.12
>Organization:
>Environment:
Linux, RHEL 4 Update 4, 2.6.9-42.0.2.EL
Self-compiled mutt
>Description:
When a mailbox contains entries with "To" addresses that consist solely of the 
email address, then sorting in the index by "To" is sometimes inconsistent.  An 
operation like "sort by to, sort by date, sort by to, sort by thread, and sort 
by to" should leave the index in the same order after each "sort by to".  
However, it does not some of the time.
>How-To-Repeat:
>Fix:
Attached is a patch that fixes this for me.  In sort.c:compare_to(), 
mutt_get_name() is called twice in a row.  In the buggy cases, 
mutt_addr_for_display() in mutt_get_name() is called twice.  In 
mutt_addr_for_display(), the returned pointer is a static variable that is 
immediately FREE'd and barring no failures is safe_realloc'ed and returned with 
results.  The patch makes a copy of the first address, so it is not destroyed 
by the second.  Identical changes were made to the compare_from() function.
>Add-To-Audit-Trail:

>Unformatted:
 ----gnatsweb-attachment----
 Content-Type: application/octet-stream; name="sort.c.patch"
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename="sort.c.patch"
 
 LS0tIHNvcnQuYy5vbGQJMjAwNS0wOS0xNyAxMzo0NjoxMS4wMDAwMDAwMDAgLTA3MDAKKysrIHNv
 cnQuYwkyMDA2LTEwLTA2IDE3OjQ2OjU2LjQ2MDg5ODAwMCAtMDcwMApAQCAtMTE0LDkgKzExNCwx
 MCBAQAogICBjb25zdCBjaGFyICpmYSwgKmZiOwogICBpbnQgcmVzdWx0OwogCi0gIGZhID0gbXV0
 dF9nZXRfbmFtZSAoKCpwcGEpLT5lbnYtPnRvKTsKKyAgZmEgPSBzYWZlX3N0cmR1cCAobXV0dF9n
 ZXRfbmFtZSAoKCpwcGEpLT5lbnYtPnRvKSk7CiAgIGZiID0gbXV0dF9nZXRfbmFtZSAoKCpwcGIp
 LT5lbnYtPnRvKTsKICAgcmVzdWx0ID0gbXV0dF9zdHJjYXNlY21wIChmYSwgZmIpOworICBGUkVF
 KCZmYSk7CiAgIEFVWFNPUlQocmVzdWx0LGEsYik7CiAgIHJldHVybiAoU09SVENPREUgKHJlc3Vs
 dCkpOwogfQpAQCAtMTI4LDkgKzEyOSwxMCBAQAogICBjb25zdCBjaGFyICpmYSwgKmZiOwogICBp
 bnQgcmVzdWx0OwogCi0gIGZhID0gbXV0dF9nZXRfbmFtZSAoKCpwcGEpLT5lbnYtPmZyb20pOwor
 ICBmYSA9IHNhZmVfc3RyZHVwIChtdXR0X2dldF9uYW1lICgoKnBwYSktPmVudi0+ZnJvbSkpOwog
 ICBmYiA9IG11dHRfZ2V0X25hbWUgKCgqcHBiKS0+ZW52LT5mcm9tKTsKICAgcmVzdWx0ID0gbXV0
 dF9zdHJjYXNlY21wIChmYSwgZmIpOworICBGUkVFKCZmYSk7CiAgIEFVWFNPUlQocmVzdWx0LGEs
 Yik7CiAgIHJldHVybiAoU09SVENPREUgKHJlc3VsdCkpOwogfQo=