From 832f9a9c6457d8c60b8f0daefd8f9cc81618e211 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 22 Aug 2009 11:45:20 +0200 Subject: [PATCH] Fix bug #356. Our sorting function was wrong if a value was between two NULL pointers. --- ir/irtypestruct.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir/irtypestruct.cpp b/ir/irtypestruct.cpp index fc5bcf39..ab63acf9 100644 --- a/ir/irtypestruct.cpp +++ b/ir/irtypestruct.cpp @@ -67,8 +67,8 @@ bool var_offset_sort_cb(const VarDeclaration* v1, const VarDeclaration* v2) { if (v1 && v2) return v1->offset < v2->offset; - else - return false; + // sort NULL pointers towards the end + return v1 && !v2; } // this is pretty much the exact same thing we need to do for fields in each