[libgfortran,committed] Bug 85840 - Memory leak in write.c

Message ID 549009a3-476d-eead-d396-aa60ceaf427d@charter.net
State New
Headers show
Series
  • [libgfortran,committed] Bug 85840 - Memory leak in write.c
Related show

Commit Message

Jerry May 26, 2018, 5:50 p.m.
The following committed as obvious after regression testing.

2018-05-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/85840
	* io/write.c (write_float_0): Use separate local variable for
	the float string length.


Author: jvdelisle
Date: Sat May 26 17:30:52 2018
New Revision: 260793

URL: https://gcc.gnu.org/viewcvs?rev=260793&root=gcc&view=rev
Log:
2018-05-26  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/85840
	* io/write.c (write_float_0): Use separate local variable for
	the float string length.

Modified:
     trunk/libgfortran/io/write.c

Patch

--- trunk/libgfortran/io/write.c	2018/05/26 11:35:31	260792
+++ trunk/libgfortran/io/write.c	2018/05/26 17:30:52	260793
@@ -1566,19 +1566,19 @@ 
    char buf_stack[BUF_STACK_SZ];
    char str_buf[BUF_STACK_SZ];
    char *buffer, *result;
-  size_t buf_size, res_len;
+  size_t buf_size, res_len, flt_str_len;

    /* Precision for snprintf call.  */
    int precision = get_precision (dtp, f, source, kind);

    /* String buffer to hold final result.  */
    result = select_string (dtp, f, str_buf, &res_len, kind);
-
+
    buffer = select_buffer (dtp, f, precision, buf_stack, &buf_size, kind);
-
+
    get_float_string (dtp, f, source , kind, 0, buffer,
-                           precision, buf_size, result, &res_len);
-  write_float_string (dtp, result, res_len);
+                           precision, buf_size, result, &flt_str_len);
+  write_float_string (dtp, result, flt_str_len);

    if (buf_size > BUF_STACK_SZ)
      free (buffer);