Ticket #243 (closed defect: fixed)

Opened 2 months ago

Last modified 2 months ago

COBIA IStream::Seek error.

Reported by: jasper Owned by: jasper
Priority: critical Milestone: Phase III
Component: COMBIA Version:
Keywords: Cc:

Description

As reported by Michael:

Malcolm/Jasper:

 

The following code in a property package Save/Load combination will illustrate the access violate on the second read of Load:

 

STDMETHODIMP

CapeThermoPropertyPackage::Load(LPSTREAM pStm)

{

              unsigned char buf[4096];

              ULONG cbRead;

              pStm->Read(buf, sizeof(buf), &cbRead);

 

              LARGE_INTEGER li;

              li.QuadPart = -4092;

              ULARGE_INTEGER libNewPosition;

              pStm->Seek(li, STREAM_SEEK_CUR, &libNewPosition);

 

              return pStm->Read(buf, sizeof(buf), &cbRead);

}

 

STDMETHODIMP

CapeThermoPropertyPackage::Save(LPSTREAM pStm, BOOL fClearDirty)

{

              unsigned char buf[7000];

              ULONG cbWritten;

              return pStm->Write(buf, sizeof(buf), &cbWritten);

}

 

Michael Hlavinka

Reply:

There is certainly an error on the <0 value of the current position pointer in the COBIA Stream implementation, but I would expect below would succeed if there was indeed 4096 bytes of data in the stream. If not, the read would return less than 4096, and the seek is invalid (and fails to return an error).

Can you check the return value of Read (how many bytes were read)?

I am correcting the <0 error.

Attachments

TestPPSaveLoad.zip (96.9 KB) - added by jasper 2 months ago.

Change History

comment:1 Changed 2 months ago by jasper

partial fix in commit de37b96

Changed 2 months ago by jasper

comment:2 Changed 2 months ago by jasper

I cannot reproduce the problem with the above update. I attached my test COM PP with the suggested seek in the load for verification.

comment:3 Changed 2 months ago by jasper

  • Status changed from new to closed
  • Resolution set to fixed

Fix confirmed by Michael.

Note: See TracTickets for help on using tickets.