This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Avoid null dereference in get_unwidened
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 10 Jan 2004 12:07:42 +0000
- Subject: [committed] Avoid null dereference in get_unwidened
A recent patch to get_unwidened meant that it would dereference
"type" before checking whether it was null. This caused a segfault
on mips64el-linux-gnu while building the libgcc TFmode support.
Bootstrapped on mips64{,el}-linux-gnu, installed as obvious.
Richard
* tree.c (get_unwidened): Reorder conditions so that the null pointer
check is done first.
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.340
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.340 tree.c
*** tree.c 20 Dec 2003 03:21:23 -0000 1.340
--- tree.c 10 Jan 2004 12:02:05 -0000
*************** get_unwidened (tree op, tree for_type)
*** 4123,4132 ****
The resulting extension to its nominal type (a fullword type)
must fit the same conditions as for other extensions. */
! if (INT_CST_LT_UNSIGNED (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (op)))
&& (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
! && (! uns || final_prec <= innerprec || unsignedp)
! && type != 0)
{
win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0),
TREE_OPERAND (op, 1));
--- 4123,4132 ----
The resulting extension to its nominal type (a fullword type)
must fit the same conditions as for other extensions. */
! if (type != 0
! && INT_CST_LT_UNSIGNED (TYPE_SIZE (type), TYPE_SIZE (TREE_TYPE (op)))
&& (for_type || ! DECL_BIT_FIELD (TREE_OPERAND (op, 1)))
! && (! uns || final_prec <= innerprec || unsignedp))
{
win = build (COMPONENT_REF, type, TREE_OPERAND (op, 0),
TREE_OPERAND (op, 1));