corrected fix to PR#2711 and also cover mime_param_cmp

This commit is contained in:
Dr. Stephen Henson 2012-03-12 16:32:19 +00:00
parent 146b52edd1
commit 78dfd43955

View File

@ -862,9 +862,8 @@ static int mime_hdr_addparam(MIME_HEADER *mhdr, char *name, char *value)
static int mime_hdr_cmp(const MIME_HEADER * const *a, static int mime_hdr_cmp(const MIME_HEADER * const *a,
const MIME_HEADER * const *b) const MIME_HEADER * const *b)
{ {
if ((*a)->name == NULL || (*b)->name == NULL) if (!(*a)->name || !(*b)->name)
return (*a)->name - (*b)->name < 0 ? -1 : return !!(*a)->name - !!(*b)->name;
(*a)->name - (*b)->name > 0 ? 1 : 0;
return(strcmp((*a)->name, (*b)->name)); return(strcmp((*a)->name, (*b)->name));
} }
@ -872,6 +871,8 @@ static int mime_hdr_cmp(const MIME_HEADER * const *a,
static int mime_param_cmp(const MIME_PARAM * const *a, static int mime_param_cmp(const MIME_PARAM * const *a,
const MIME_PARAM * const *b) const MIME_PARAM * const *b)
{ {
if (!(*a)->param_name || !(*b)->param_name)
return !!(*a)->param_name - !!(*b)->param_name;
return(strcmp((*a)->param_name, (*b)->param_name)); return(strcmp((*a)->param_name, (*b)->param_name));
} }