Program: 43949
Project: 43949
Buggy source:
protected Varargs oncallv(int opcode,Varargs args){
  File f;
  int n;
  LuaValue v;
  try {
switch (opcode) {
case IO_FLUSH:
      checkopen(output());
    outfile.flush();
  return LuaValue.TRUE;
case IO_TMPFILE:
return tmpFile();
case IO_CLOSE:
f=args.arg1().isnil() ? output() : checkfile(args.arg1());
checkopen(f);
return ioclose(f);
case IO_INPUT:
infile=args.arg1().isnil() ? input() : args.arg1().isstring() ? ioopenfile(args.checkString(1),"String_Node_Str") : checkfile(args.arg1());
return infile;
case IO_OUTPUT:
outfile=args.arg1().isnil() ? output() : args.arg1().isstring() ? ioopenfile(args.checkString(1),"String_Node_Str") : checkfile(args.arg1());
return outfile;
case IO_TYPE:
if ((f=optfile(args.arg1())) != null) return f.isclosed() ? CLOSED_FILE : FILE;
return NIL;
case IO_POPEN:
return openProgram(args.checkString(1),args.optString(2,"String_Node_Str"));
case IO_OPEN:
return rawopenfile(args.checkString(1),args.optString(2,"String_Node_Str"));
case IO_LINES:
infile=args.arg1().isnil() ? input() : ioopenfile(args.checkString(1),"String_Node_Str");
checkopen(infile);
return lines(infile);
case IO_READ:
checkopen(infile);
return ioread(infile,args);
case IO_WRITE:
checkopen(output());
return iowrite(outfile,args);
case FILE_CLOSE:
return ioclose(checkfile(args.arg1()));
case FILE_FLUSH:
checkfile(args.arg1()).flush();
return LuaValue.TRUE;
case FILE_SETVBUF:
f=checkfile(args.arg1());
f.setvbuf(args.checkString(2),args.optint(3,1024));
return LuaValue.TRUE;
case FILE_LINES:
return lines(checkfile(args.arg1()));
case FILE_READ:
f=checkfile(args.arg1());
return ioread(f,args.subargs(2));
case FILE_SEEK:
f=checkfile(args.arg1());
n=f.seek(args.optString(2,"String_Node_Str"),args.optint(3,0));
return valueOf(n);
case FILE_WRITE:
f=checkfile(args.arg1());
return iowrite(f,args.subargs(2));
case IO_INDEX:
v=args.arg(2);
return v.equals(STDOUT) ? output() : v.equals(STDIN) ? input() : v.equals(STDERR) ? errput() : NIL;
case LINES_ITER:
f=checkfile(env);
return freadline(f);
}
}
 catch (Exception ioe) {
return errorresult(ioe);
}
return NONE;
}

Fixed version (ground truth):
protected Varargs oncallv(int opcode,Varargs args){
  File f;
  int n;
  LuaValue v;
  try {
switch (opcode) {
case IO_FLUSH:
      checkopen(output());
    outfile.flush();
  return LuaValue.TRUE;
case IO_TMPFILE:
return tmpFile();
case IO_CLOSE:
f=args.arg1().isnil() ? output() : checkfile(args.arg1());
checkopen(f);
return ioclose(f);
case IO_INPUT:
infile=args.arg1().isnil() ? input() : args.arg1().isstring() ? ioopenfile(args.checkString(1),"String_Node_Str") : checkfile(args.arg1());
return infile;
case IO_OUTPUT:
outfile=args.arg1().isnil() ? output() : args.arg1().isstring() ? ioopenfile(args.checkString(1),"String_Node_Str") : checkfile(args.arg1());
return outfile;
case IO_TYPE:
if ((f=optfile(args.arg1())) != null) return f.isclosed() ? CLOSED_FILE : FILE;
return NIL;
case IO_POPEN:
return openProgram(args.checkString(1),args.optString(2,"String_Node_Str"));
case IO_OPEN:
return rawopenfile(args.checkString(1),args.optString(2,"String_Node_Str"));
case IO_LINES:
infile=args.arg1().isnil() ? input() : ioopenfile(args.checkString(1),"String_Node_Str");
checkopen(infile);
return lines(infile);
case IO_READ:
checkopen(infile);
return ioread(infile,args);
case IO_WRITE:
checkopen(output());
return iowrite(outfile,args);
case FILE_CLOSE:
return ioclose(checkfile(args.arg1()));
case FILE_FLUSH:
checkfile(args.arg1()).flush();
return LuaValue.TRUE;
case FILE_SETVBUF:
f=checkfile(args.arg1());
f.setvbuf(args.checkString(2),args.optint(3,1024));
return LuaValue.TRUE;
case FILE_LINES:
return lines(checkfile(args.arg1()));
case FILE_READ:
f=checkfile(args.arg1());
return ioread(f,args.subargs(2));
case FILE_SEEK:
f=checkfile(args.arg1());
n=f.seek(args.optString(2,"String_Node_Str"),args.optint(3,0));
return valueOf(n);
case FILE_WRITE:
f=checkfile(args.arg1());
return iowrite(f,args.subargs(2));
case IO_INDEX:
v=args.arg(2);
return v.equals(STDOUT) ? output() : v.equals(STDIN) ? input() : v.equals(STDERR) ? errput() : NIL;
case LINES_ITER:
f=checkfile(env);
return freadline(f);
}
}
 catch (IOException ioe) {
return errorresult(ioe);
}
return NONE;
}