So where's the fdopen() call in your code?
Sure you're not compiling release, then running some ancient debug from some previous project?
When you run the code in debug mode, and get an assert, you should be able to view the stack trace of how you got to that point.
Click on each line of the stack trace until you get to your code. Then figure out what parameter you're passing to the current API call is bad.