How can I cause a "initscr" break with ncurses?

Apitronix

I know this is a weird question, but I want to get the "initscr" function error mentioned by the doc (getting invalid pointer and an error message on stderr) to test if a wrapper works properly.

But I don't find any information about that. I'm currently working with ncurses 6.2.

After few research, I have found that the invalid pointer is really a NULL, not just an empty one pointing on anywhere.

But I'm not able to break the function...

If someone know how to help me to break down this, feel free to leave a comment.

KamilCuk

The following program:

#include <curses.h>
#include <malloc.h>
#include <stdlib.h>

bool my_malloc_disabled;
void *malloc(size_t size) {
    if (my_malloc_disabled) {
        return NULL;
    }
    void *__libc_malloc(size_t);
    return __libc_malloc(size);
}
int main() {
    my_malloc_disabled = 1;
    initscr();
}

does:

$ gcc file.c -lcurses
$ ./a.out
Error opening allocating $TERM.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related