This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR29101 - Memory leak in select case with character expression


On 9/18/06, Paul Thomas <paulthomas2@wanadoo.fr> wrote:
Bingo! You're right....  It was just too "obvious" wasn't it.  I posted
a corrected version with the PR.

Paul,


What you now commited is still wrong.

  pstr.6 = (char[1:D.960] *) _gfortran_internal_malloc (D.960);
  tolower (pstr.6, D.960, D.958, D.959);
  goto _gfortran_select_string ((void *) &jumptable.5, 2, &L.5, pstr.6,
D.960);
  L.4:;
  *value = 1;
  goto L.5;
  L.3:;
  __result_validate_value = 0;
  goto L.5;
  L.5:;
  _gfortran_internal_free ((void *) pstr.6);

For example, what if one of the CASEs jumps to a label beyond the end
of the SELECT?  Like so:

 LOGICAL FUNCTION foo(str)
   USE stringutils
   CHARACTER(len=*), INTENT(in) :: str
   SELECT CASE (tolower(str))
     CASE ("x"):
       foo = .TRUE.
       GOTO 10
     CASE DEFAULT
       foo = .FALSE.
   END SELECT
10  CONTINUE
 END FUNCTION

I bet this still leaks.

Gr.
Steven


Gr. Steven


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]