From d9f957300ef8447392494db7db6fdc72ba7a82c1 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 16 Oct 2021 15:19:10 +0000 Subject: [PATCH] null-terminated a string before passing to a C function --- lib2/Makefile | 4 ++-- lib2/hello2.adb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib2/Makefile b/lib2/Makefile index 2437039..9e456ff 100644 --- a/lib2/Makefile +++ b/lib2/Makefile @@ -1,3 +1,3 @@ all: - gnat make -gnata hello && valgrind ./hello - gnat make -gnata hello2 && valgrind ./hello2 + gnat make -gnata -gnatW8 hello && valgrind ./hello + gnat make -gnata -gnatW8 hello2 && valgrind ./hello2 diff --git a/lib2/hello2.adb b/lib2/hello2.adb index fa4c968..91fd479 100644 --- a/lib2/hello2.adb +++ b/lib2/hello2.adb @@ -76,7 +76,8 @@ procedure hello2 is end case; end is_class; - Empty_String: aliased Standard.String := ""; + --Empty_String: aliased Standard.String := "en_US.utf8" & Standard.Character'Val(0); + Empty_String: aliased Standard.String := "" & Standard.Character'Val(0); begin --setlocale (6, Interfaces.C.Strings.To_Chars_Ptr(Empty_String'access)); setlocale (6, Empty_String'Address);