[Bug fortran/41823] New: gcc/fortran/trans-openmp.c: possible null pointer dereference

dcb314 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Sun Oct 25 11:11:00 GMT 2009


I just had a look at the source code file
gcc/fortran/trans-openmp.c,
function gfc_trans_omp_do.

I notice the following code

  gfc_omp_clauses *clauses = code->ext.omp_clauses;
  gfc_code *outermost;
  int i, collapse = clauses->collapse;

where the assumption is made that local variable "clauses" is non-NULL
and so local variable "collapse" can be assigned to ok.

Later code is

  for (i = 0; i < collapse; i++)
    {
      int simple = 0;
      int dovar_found = 0;

      if (clauses)

where a test is made for local variable "clauses" to be NULL or not.

Suggest code rework to cope with clauses being NULL. Maybe the following
untested code would be enough

  int i, collapse = (clauses ? clauses->collapse : 0);


-- 
           Summary: gcc/fortran/trans-openmp.c: possible null pointer
                    dereference
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dcb314 at hotmail dot com
  GCC host triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41823



More information about the Gcc-bugs mailing list