c++ - malloc / new fails from within a function pointer -


i have following structure definitions:

struct  info_link {     char                url[100];     http_response       *(*worker)(http_request *request, char *arguments);     long                url_length; }; 

as can see, "worker" function pointer.
now, have following function:

http_response   *info_show_providers(http_request *request, char *arguments) {     char        *test = new char[100];     long        = 5; } 

and define simple info_link array 1 member in it, follows:

info_link       internal_links[] = {                 {"/show_providers", info_show_providers, 15} }; 

i'm trying call:

internal_links[0].worker(x,x); 

and program access "info_show_providers" function, fails on "new char[100]" function every time it.
throws sigabrt.

way i'm calling function pointer isn't right? or corrupts stack?
how should done properly?

glibc's malloc can raise sigabrt if heap corrupted. 2 scenarios pop mind:

1) withing signal handler (and shouldn't call malloc).

2) have memory corruption elsewhere trashed heap (e.g.: overflows/underflows common cause of heap corruption).


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -