Fix state->max_msg being read and written to within same statement.

state->max_msg is read and changed in the same function call to local_realloc(); this might cause trouble depending on how (i.e. in which order) the compiler evaluates the parameters.