Firstly, attaching the pilot file should help, as I'm still trying to work out how to reproduce the issue. I think one of the complexities is that the problem occurs at time X, but it doesn't manifest until time Y which can be a while after time X, thus making it hard to figure out what you were doing when the problem actually occurred.
Secondly, on repairing pilot files...
1) You need to find the red-alert section in the relevant .csg file. This is easy with a busted file, since it'll be 99%+ comprised of the red-alert section

If you open the .csg in a hex editor you'll see shipnames repeated over and over, perhaps millions of times. This is data from the last red alert mission that you played.
2) You remove all the data from the red-alert section EXCEPT for one "set" of red alert data. i.e. each ship & its data should only be listed once. Since I'm on Linux the tools I used for this were "head -c / tail -c / cat" to remove the bad data and patch the file back together, with a hex editor (ghex2) to provide me with the relevant byte offsets in the file.
3) You need to find the integer value in the .csg which records the number of red alert entries and modify it so that it matches with the number of ships stored in the red alert section. Remember that integers on little-endian x86 CPUs are stored LSB (least significant byte) first, so you need to reverse the order of the 4 bytes that make up the integer when you insert your new value (e.g hex 01 00 00 00 for "1" instead of hex 00 00 00 01). This is the bit that you really need to read the code for, to work out what order FSO expects all the .csg data to be in and therefore be able to find the correct 4 byte section of the file to modify.
Honestly, it's fiddly and very prone to error. It's probably easier to create a new pilot file & replay your current campaign

(unless you're a masochist like me who wanted to learn how the pilot file worked

)
edit: what the hey, here's the part of the code you need to start reading: function pilotfile::save_savefile() in code/pilotfile/csg.cpp.
edit2: if you don't want to hex-edit your pilot, you've got some other options
1) start a new pilot and use CTRL-SHIFT-S in the techroom to unlock all the campaign missions, then play them one by one from here (note: you won't get medals, and campaign persistent variables may not work)
2) start a new pilot, and create a custom .fc2 (i.e. campaign file) that starts from the mission where you encountered the problem
3) start a new pilot, and play the entire campaign again
In all cases, you should also get a more recent FSO executable, as this bug is now fixed in the recent BP builds, and the recent 3.6.19 nightlies