Hey,

Can you guys try this diff?

http://ix.io/286T

On 22/01/20 20:35 -0500, Ted Unangst wrote:
> Today's selected c++ reading:
>       Before any call to str() that uses the result as a C string,
>       the buffer must be null-terminated, typically with std::ends.
> 
> Found by mlarkin using MALLOC_OPTIONS=SU.
> 
> I leave it to the ports wizards to incorporate the patch.
> 
> 
> --- OptionsParser.cc.orig     Wed Aug  4 19:23:39 1999
> +++ OptionsParser.cc  Wed Jan 22 20:32:29 2020
> @@ -17,8 +17,8 @@
>      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>  */
>  
> -#include <iostream.h>
> -#include <strstream.h>
> +#include <iostream>
> +#include <strstream>
>  #include <string.h>
>  #include <stdio.h>
>  #include <stdlib.h>
> @@ -27,6 +27,8 @@
>  #include "Info.h"
>  #include "Usage.h"
>  
> +using namespace std;
> +
>  // methods for class Options
>  
>  Options::Options()
> @@ -138,6 +140,7 @@
>                 {
>                    // found seperator
>                    // set filename in options class
> +                  filename << std::ends;
>                    o->cfg_filenames[o->nr_cfg_files] = filename.str();
>  
>                    // increase the nr_cfg_files counter
> @@ -154,6 +157,7 @@
>                 {
>                    // found end of string
>                    // set filename in options class
> +                  filename << std::ends;
>                    o->cfg_filenames[o->nr_cfg_files] = filename.str();
>  
>                    // increase the nr_cfg_files counter
> 

-- 
Regards,
Robert Nagy

Reply via email to