# New Ticket Created by  NotFound 
# Please include the string:  [perl #58438]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58438 >


I was doing a simple test of NCI calls with the xlib function
XDisplayName, and found that nci can't handle a NULL string argument.
Passing a NULL Parrot String segfaults.

The attached patch passes a NULL char * when a NULL Parrot String is
used. Don't know if this is the desired behaviour, I expect comments.

-- 
Salu2
Index: tools/build/nativecall.pl
===================================================================
--- tools/build/nativecall.pl	(revision 30618)
+++ tools/build/nativecall.pl	(working copy)
@@ -505,8 +505,8 @@
     /t/ && do {
         push @{$temps_ref}, "char *t_$temp_num;";
         push @{$extra_preamble_ref},
-            "t_$temp_num = string_to_cstring(interp, GET_NCI_S($reg_num));";
-        push @{$extra_postamble_ref}, "string_cstring_free(t_$temp_num);";
+            "{STRING * s= GET_NCI_S($reg_num); t_$temp_num = s ? string_to_cstring(interp, s) : (char *) NULL;}";
+        push @{$extra_postamble_ref}, "do { if (t_$temp_num) string_cstring_free(t_$temp_num); } while (0);";
         return "t_$temp_num";
     };
     /b/ && do {

Reply via email to