From 7a21da90fdd8ae92ba2a0fff5443c39253a5a5a6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Feb 2022 22:50:28 +1300 Subject: [PATCH] [C#] Fix memory leak in directorin typemap for std::string. Fixes #998 --- CHANGES.current | 4 ++++ Lib/csharp/std_string.i | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index aa1816ae8..9ec78b631 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-02-03: olly + [C#] #283 #998 Fix memory leak in directorin typemap for + std::string. + 2022-02-03: olly [Python] #967 Make `self` parameter available to user typemaps. diff --git a/Lib/csharp/std_string.i b/Lib/csharp/std_string.i index 5f8fa44cb..79b71c4c5 100644 --- a/Lib/csharp/std_string.i +++ b/Lib/csharp/std_string.i @@ -20,7 +20,7 @@ namespace std { class string; // string -%typemap(ctype) string "char *" +%typemap(ctype) string "const char *" %typemap(imtype) string "string" %typemap(cstype) string "string" @@ -42,7 +42,7 @@ class string; } $result.assign($input); %} -%typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %} +%typemap(directorin) string %{ $input = $1.c_str(); %} %typemap(csin) string "$csinput" %typemap(csout, excode=SWIGEXCODE) string {