0

So this is how may load

bool load(FILE* file, BYTE** content, size_t* length)
{
if(file == NULL)
return false;

unsigned int size = 0;
while(fgetc(file) != EOF)
{
    size++;
}
*length = size;
rewind(file);
BYTE info[size];


for(int i = 0; i < size; i++)
{
    info[i] = fgetc(file);
}

*content = info;
return true;

}

and my indexes

char* indexes(const char* path)
{   
char* newpath_1 = malloc(strlen(path)+11);
char* newpath_2 = malloc(strlen(path)+12);
newpath_1 = strcpy(newpath_1,path);
newpath_2 = strcpy(newpath_2,path);

strcat(newpath_1,"/index.php");
strcat(newpath_2,"/index.html");

if(access(newpath_1,F_OK) == 0)
{
free(newpath_2);
return newpath_1;
}

else if(access(newpath_2,F_OK) == 0)
{
free(newpath_1);
return newpath_2;
}

else
{
free(newpath_1);
free(newpath_2);
return NULL;
}

}

I checked it and most of the results are sth like this

\ expected an exit code of 0, not standard error of "======= Backtrace: =========\n======= M..."

I've already checked my parse,lookup etc. I suspect my mistake is in not allocating dynamic space for load, but I suppose my method is also valid. So, I'm stuck....

0

Before you spend too much time troubleshooting and debugging load, read this. php files are sent to load as pipelines, you cannot rewind a pipe. You need to adjust your approach.

That result from check50 is a seg fault, and I suspect your mistake is the same as what you suspect, to wit "not allocating dynamic space". You have not allocated any space for *content, so seg fault. You will probably have to get familiar with the realloc() function.

indexes looks ok, but you will be able to verify that once you have a proper load.

You must log in to answer this question.

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