Package: glibc-doc
Version: 2.3.2.ds1-8
Severity: minor

The node "Dynamic String Input" contains this example:

>    {
>      char *variable, *value;
>    
>      if (2 > scanf ("%a[a-zA-Z0-9] = %a[^\n]\n",
>                     &variable, &value))
>        {
>          invalid_input_error ();
>          return 0;
>        }
>    
>      ...
>    }

If scanf returns 1, then it has allocated memory for one string
and assigned it to variable.  That string should be freed.
Please change the example to:

>    {
>      char *variable = NULL, *value = NULL;
>    
>      if (2 > scanf ("%a[a-zA-Z0-9] = %a[^\n]\n",
>                     &variable, &value))
>        {
>          free (variable);
>          free (value);
>          invalid_input_error ();
>          return 0;
>        }
>    
>      ...
>    }

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux Astalo 2.4.21-kon.astalo.1 #1 la elokuun 23. 01:05:31 EEST 2003 
i686
Locale: LANG=fi_FI.UTF-8, LC_CTYPE=fi_FI.UTF-8

-- no debconf information



Reply via email to