code_junkie

Run-Time Check Failure #2 - Stack around the variable 'x' was corrupted

Nov 12th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. String GetVariableName(CString symbol, CString filepath)
  2. {
  3. char acLine[512];
  4. char acPreviousLine[512];
  5. CString csFile;
  6. FILE *fp;
  7.  
  8. csFile.Format("%svariables.txt", filepath);
  9.  
  10. fp = fopen(csFile, "r");
  11.  
  12. if (! fp)
  13. return("");
  14.  
  15. for (;;)
  16. {
  17. strcpy(acPreviousLine, acLine);
  18.  
  19. // NULL means we are out of lines in the file.
  20. if (myfgets(acLine, 511, fp) == NULL)
  21. break;
  22.  
  23. // "END" indicates end of file
  24. if (! strcmp(acLine, "END"))
  25. break;
  26.  
  27. if (! strcmp(acLine, csVarSymbol))
  28. {
  29. // Previous line should be variable name
  30. fclose(fp);
  31.  
  32. // Following line results in Check Failure while in Debug mode
  33. return(acPreviousLine);
  34. }
  35. }
  36. fclose(fp);
  37. return("");
  38. }
Add Comment
Please, Sign In to add comment