Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6801933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:09:42+00:00 2026-05-26T19:09:42+00:00

I can’t get to know why do I keep getting this segmentation fault in

  • 0

I can’t get to know why do I keep getting this segmentation fault in this function
Could anyone enlighten me about how to get rid of it and get my program to work…?

Lign 33 : flux = opendir(path);
Lign 98 : ret = listdir(env, stock, pos, stock->stock_name[stock->i]);

int     listdir(t_env* env, t_stock* stock, t_pos* pos, char* path)
{
        struct dirent*  dirinfo;
        DIR*            flux;

        init_xy(pos);
        cl_screen(env);

        flux = opendir(path);
        if (flux == NULL)
                return (1);
        alloc_mem(stock);
        stock->i = 0;
        while ((dirinfo = readdir(flux)))
        {
                id_strcpy(stock->stock_name[stock->i], dirinfo->d_name);               
                print_list(env, pos);
                id_print_str(stock->stock_name[stock->i]);
                pos->y = pos->y + 1;
                stock->i = stock->i + 1;
        }
        stock->i = stock->i - 1;
        pos->y = pos->y - 1;
        pos->ymax = pos->y;
        closedir(flux);
        return (0);
}

void    enter(t_env* env, t_pos* pos, t_stock* stock)
{
        int     ret;

        (void)pos;
        cl_screen(env);
        frame(env);
        ret = listdir(env, stock, pos, stock->stock_name[stock->i]);

        ret = 0;
        if (ret == 1)
        {
                free_mem(stock);
                reset_keypress();
                exit(1);
        }
        stock->i = 0;
}

(gdb) where
#0  __opendir (name=0x0) at ../sysdeps/unix/opendir.c:86
#1  0x08048ebb in listdir (env=0xbffff890, stock=0xbffff880, pos=0xbffff86c, path=0x0) at listdir.c:33
#2  0x080494ad in enter (env=0xbffff890, pos=0xbffff86c, stock=0xbffff880) at run_fct.c:98
#3  0x0804930a in press (env=0xbffff890, pos=0xbffff86c, stock=0xbffff880, arrows=0xbffff82d "\n") at run_fct.c:51
#4  0x080491db in run (env=0xbffff890, pos=0xbffff86c, stock=0xbffff880) at run_fct.c:25
#5  0x08048985 in main (argc=2, argv=0xbffff954) at main.c:35
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:09:43+00:00Added an answer on May 26, 2026 at 7:09 pm

    Your backtrace shows that you’re passing NULL as the name parameter to opendir(). That’s not going to work. It looks like your stock data structure in enter() isn’t filled in with what you expect it to be. In particular, stock->stock_name[stock->i] is NULL at the time you make the failing call to opendir().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
Can you cast a List<int> to List<string> somehow? I know I could loop through
can anyone tell me why this doesn't work? db = openOrCreateDatabase(database.db, SQLiteDatabase.CREATE_IF_NECESSARY, null); db.setLocale(Locale.getDefault());
Can anyone help me trying to find out why this doesn't work. The brushes
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can anyone tell me how I can display a status message like 12 seconds
Can I get a 'when to use' for these and others? <% %> <%#
Can anyone recommend a good library for generating an audio file, such as mp3,
Can anyone give me an example of how to return the following json simply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.