idnode: fix sorting due to use of potentially static return values.

This commit is contained in:
Adam Sutton 2013-07-09 16:09:31 +01:00
parent 35b30871bd
commit cc144adabf

View file

@ -375,12 +375,15 @@ idnode_cmp_sort
switch (p->type) {
case PT_STR:
{
const char *stra = idnode_get_str(ina, sort->key);
int r;
char *stra = strdup(idnode_get_str(ina, sort->key) ?: "");
const char *strb = idnode_get_str(inb, sort->key);
if (sort->dir == IS_ASC)
return strcmp(stra ?: "", strb ?: "");
r = strcmp(stra ?: "", strb ?: "");
else
return strcmp(strb ?: "", stra ?: "");
r = strcmp(strb ?: "", stra ?: "");
free(stra);
return r;
}
break;
case PT_INT: