![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Function crashes on return
bBool bFileB::open(bString f) {
fhandle = fopen(f.c_str(), "rb+");
int currpos = 4;
if(!fhandle)
return false;
int signature;
fread(&signature, sizeof(int), 1, fhandle);
if(signature != B_FILEB_HEADER) {
fclose(fhandle);
return false;
}
fseek(fhandle, 0, SEEK_END);
if(ftell(fhandle) == 4)
return true;
/* read the headers */
while(true) {
bFileB_rawsubheader h;
fseek(fhandle, currpos, SEEK_SET);
if(feof(fhandle))
break;
if(fread(&h, 1, sizeof(bFileB_rawsubheader), fhandle) != sizeof(bFileB_rawsubheader))
break;
if(h.signature != B_FILEB_SUBHEADER) {
fclose(fhandle);
return false;
}
bFileB_subheader h2;
h2.length = h.length;
h2.start = currpos + sizeof(bFileB_subheader);
h2.name = bString(h.name);
headers.push_back(h2);
currpos += sizeof(bFileB_subheader) + h.length;
}
return true;
}Ok, so I have this function. The problem is that I get a runtime error (Expression: _CtrIsValidHeapPointer(pUserData)) at the darkred marked line. I think my stack gets fucked up somewhere, but how? TIA ![]() |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Never mind, I fixed it. It was the string as argument, making a pointer to a string of it did it.
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Aren't you supposed to close the filehandle before you break?
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#4 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Expert Programmer
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4
![]() |
Hey Poly, did you set an expected beta release date for the OS you're working on yet?
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
You're working on an OS Poly? I'd be glad to help if I had some time, wanted to get some experience with it.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|