{"action":"closed","issue":{"url":"https://api.github.com/repos/neurodroid/stimfit/issues/11","labels_url":"https://api.github.com/repos/neurodroid/stimfit/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/neurodroid/stimfit/issues/11/comments","events_url":"https://api.github.com/repos/neurodroid/stimfit/issues/11/events","html_url":"https://github.com/neurodroid/stimfit/issues/11","id":54974662,"number":11,"title":"std::vector index out of range reading gap-free abf. It seems that m_pFI->m_uLastEpiSize may never be set.","user":{"login":"kh90909","id":7075951,"avatar_url":"https://avatars.githubusercontent.com/u/7075951?v=3","gravatar_id":"","url":"https://api.github.com/users/kh90909","html_url":"https://github.com/kh90909","followers_url":"https://api.github.com/users/kh90909/followers","following_url":"https://api.github.com/users/kh90909/following{/other_user}","gists_url":"https://api.github.com/users/kh90909/gists{/gist_id}","starred_url":"https://api.github.com/users/kh90909/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kh90909/subscriptions","organizations_url":"https://api.github.com/users/kh90909/orgs","repos_url":"https://api.github.com/users/kh90909/repos","events_url":"https://api.github.com/users/kh90909/events{/privacy}","received_events_url":"https://api.github.com/users/kh90909/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-21T03:54:11Z","updated_at":"2015-06-14T20:28:26Z","closed_at":"2015-06-14T20:28:26Z","body":"I've run into another of these `std::vector::operator[]` index out of range checks that seem to be enabled only in VS2008 builds. However, I think this one might point to an underlying bug.\r\n\r\nWhen reading a gap-free file larger than `maxsize`, [`ABF2_GetNumSamples()`](https://github.com/neurodroid/stimfit/blob/b8326dbafa01ace1eb115ae84c1f9a236bd0fac1/src/libstfio/abf/abflib.cpp#L214) appears to always set `uNumSamples` to zero for the last episode. This results in a zero length `TempSection` vector being passed to [`ABF2_ReadChannel()`](https://github.com/neurodroid/stimfit/blob/b8326dbafa01ace1eb115ae84c1f9a236bd0fac1/src/libstfio/abf/abflib.cpp#L230), which triggers the index out of range error when passing `&pfBuffer[0]` to [`ConvertADCToFloats()`](https://github.com/neurodroid/stimfit/blob/b8326dbafa01ace1eb115ae84c1f9a236bd0fac1/src/libstfio/abf/axon/AxAbfFio32/abffiles.cpp#L2348).\r\n\r\nFor the last episode only, [`ABF2_GetNumSamples()`](https://github.com/neurodroid/stimfit/blob/b8326dbafa01ace1eb115ae84c1f9a236bd0fac1/src/libstfio/abf/abflib.cpp#L214) calls [`pFI->GetLastEpiSize()`](https://github.com/neurodroid/stimfit/blob/b8326dbafa01ace1eb115ae84c1f9a236bd0fac1/src/libstfio/abf/axon/AxAbfFio32/abffiles.cpp#L3344) to get the number of samples, which in turn returns `m_uLastEpiSize`. As far as I can tell, `m_uLastEpiSize` is not getting set anywhere, but I'm not familiar enough with the code to know for sure. Consequently, I'm not sure how or where to set it to fix this issue.\r\n\r\n(Click on the function names in the above to go to the relevant calls in the code)"}}