次のコードがあります。
char *passwordFunc(const char *s)
{
static char *pw = NULL;
if (strlen(s)) {
pw = s;
}
return pw;
}
void keyboard_interactive(const char *name, int name_len, const char *instr, int instr_len,
int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE *res,
void **abstract)
{
char *text = passwordFunc("");
res[0].text = strdup(text);
res[0].length = strlen(text);
}
デバッガーによると、 の行に到達するたびstrdup(text)
にEXC_BAD_ACCESS (code=2, address=0x0)
.
何が起こっているのか、それを修正する方法について何か提案はありますか? 前もって感謝します。