Permalink
Browse files

Don't increment the fileid until after the file has been opened

  • Loading branch information...
1 parent e6ff0a0 commit 80ac662cecea2511b295c2a00cee852ed37eed27 @atrodo committed Feb 9, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 loader.c
View
7 loader.c
@@ -79,13 +79,14 @@ lorito_load_bytecode(Lorito_Interp *interp, Lorito_Str* filename)
Lorito_File *
loadbc(Lorito_Interp *interp, const char* filename)
{
- int fileid = interp->next_fileid++;
- int segid = 0;
FILE *input = fopen(filename, "rb");
if (input == NULL) {
- return;
+ return NULL;
}
+ int fileid = interp->next_fileid++;
+ int segid = 0;
+
if (fileid >= interp->allocated_file)
{
interp->allocated_file += 4;

0 comments on commit 80ac662

Please sign in to comment.