I'm getting this error when I try to run my server. I don't what's been causing it.

char* indexes(const char* path)
    char* path_php = malloc(sizeof(char) * strlen(path));
    char* path_html = malloc(sizeof(char) * strlen(path));
    strcpy(path_php, path);
    strcpy(path_html, path);
    strcat(path_php, "/index.php");
    strcat(path_html, "/index.html");

    if (access(path_php, F_OK) == 0)
        return path_php;
    if (access(path_html, F_OK) == 0)
        return path_html;

    return NULL;
  • I was getting a similar error until I got rid of the free() statements. I am not sure why this worked but valgrind gave me now errors and I got no errors from CS50. Commented Jun 5, 2016 at 21:52

1 Answer 1


sizeof (char), the sizeof operator returns the size in bytes of char, most likely to be 1, so that path_php has the same longuitud that path. Sure you know which is the mistake that you make.

  • Wow, how come I didn't see that? Thanks a lot! Commented Jun 5, 2016 at 18:41
  • glad to help, onwards!
    – MARS
    Commented Jun 5, 2016 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .