Contextualizing, after compiling my code I'm receiving a SEGV signal, which is related to unauthorized access of memory. Given the source and that the code was working before recent changes. Why am I receiving this signal?
Note: Motif's type return explained
Returns a character pointer to the string value of the TextField widget. This returned value is a copy of the value of the XmNvalue resource. Returns an empty string if the length of the TextField widget’s string is 0 (zero).
Declaration:
char *str, *str1, *str2;
Previous initialization:
str2 = XmTextFieldGetString( WIDGET_WITH_STRING );
Current initialization:
str2[0] = "Group Definition";
Exception:
(dbx) cont
dbx: warning: Resuming only t@1 to satisfy events that require
automatic single-stepping
trace: 814 if (!add_button_sensitive)
trace: 817 str = XmTextFieldGetString( region_code_text );
trace: 818 str1 = XmTextFieldGetString( region_name_text );
trace: 823 str2[0] = "Group Definition";
t@1 (l@1) signal SEGV (access to address exceeded protections) in
region_add_mod_cb at line 823 in file "region_groups.c"
823 str2[0] = "Group Definition";
str2
is not initialized at all in your code, so it can have any random value. And de-referencing it may cause segfault.
Also str2[0]
is char
while you are assigning it a 'char *' "Group Definition"
, which is not correct. You want str2 = "Group Definition";
?