Commits on Sep 1, 2016

  1. fclose() the memstream when we are done with it

    The documentation says
    
      The locations pointed to by ptr and sizeloc are used to report,
      respectively, the current location and the size of the buffer.  The
      locations referred to by these  pointers  are  updated each time the
      stream is flushed (fflush(3)) and when the stream is closed
      (fclose(3)).
    
    so we need to close it before reading from the pointer. To do this we
    move the memstream handling into the `if` block where it is needed.
    Iain Lane committed Sep 1, 2016