I’m having some trouble with c code from a library that I use with Android NDK.
It works on the emulator, but not on a real device. It gives me a “libc – Fatal signal 11” (SIGSEGV)
I have traced the problem to a piece of code in the library, but I’m having trouble understanding what the second line does.
Here is the code:
int lookup_mpz(mpz_t z, const char *(*tab)(const char *), const char *key) {
const char *data= tab(key); //--> Causes SEGV
if (!data) {
pbc_error("missing param: `%s'", key);
return 1;
}
mpz_set_str(z, tab(key), 0);
return 0;
}
The second line is invoking a function, via a function pointer named
tab. The function has the signature:Suggest checking that
keyandtab()are not NULL prior to callingtab().