cancel
Showing results for 
Search instead for 
Did you mean: 

Segmentation fault

Creator
Creator

Hello,

I am getting a segmentation fault in the following function:

vector<tag_t> GetGroupRole_Tags(vector<string> groupRole_Info, string tag_type)
{
                vector<tag_t> v_tags;
                for (int i = 0; i < groupRole_Info.size(); i++)
                {
                               vector<string> a = split( groupRole_Info[i], '/' );     // groupRole_Info[i] = Development/Developer
                               cout << "GROUP: " << a[0] << " ROLE: " << a[1] << endl;

                               const char *group_name = a[0].c_str();     //stores: Development
                               const char *role_name = a[1].c_str();        //stores: Developer
                               const char *user_id = NULL;
                               int *member_found = 0;
                               tag_t *output_tag;

                               SA_find_groupmember_by_rolename(role_name, group_name, user_id, member_found, &output_tag); 

    }
                return v_tags;
}

The error is on the line:

SA_find_groupmember_by_rolename(role_name, group_name, user_id, member_found, &output_tag);

Can anyone please help me debug it. Thanks.

2 REPLIES

Re: Segmentation fault

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi,

 

I have not compiled or linked this code, but I would have done something like this.

Let us know if it sorts out the segmentation fault.

 

Harish

 

vector<tag_t> GetGroupRole_Tags(vector<string> groupRole_Info, string tag_type)
{
                vector<tag_t> v_tags;
char *group_name = NULL;
char *role_name = NULL;
char *user_id = NULL;
int member_found = 0;
tag_t *output_tag = NULL;
for (int i = 0; i < groupRole_Info.size(); i++) { vector<string> a = split( groupRole_Info[i], '/' ); // groupRole_Info[i] = Development/Developer cout << "GROUP: " << a[0] << " ROLE: " << a[1] << endl;

if (tc_strcmp(a[0].c_str(),"")!= 0) {
group_name = (char *)a[0].c_str(); //stores: Development
}
if (tc_strcmp(a[1].c_str(),"")!=0) {
role_name = (char *)a[1].c_str(); //stores: Developer
} SA_find_groupmember_by_rolename(role_name, group_name, user_id, &member_found, &output_tag); } return v_tags; }

 

Re: Segmentation fault

Creator
Creator

Hi,

the segmentation fault has been resolved. The problem was with the following output parameter:

int *member_found = 0;

Thank you for your help.