dukus / digiCamControl

DSLR camera remote control open source software
http://digicamcontrol.com/
Other
654 stars 224 forks source link

BaseMTPCamera GetObjects Exception : Index was out of range. #411

Open sahaine opened 7 months ago

sahaine commented 7 months ago

I encountered an error today relating to retrieving images from a Nikon D5:

It related to CameraControl.Devices\BaseMTPCamera and the method:

public override AsyncObservableCollection GetObjects(object storageId, bool loadThumbs)

When checking the response data the array can ben empty but not null, I believe we should check the array length to ensure there is data before trying to covert it. the call:

int objCount = BitConverter.ToInt32(response.Data, 0); Threw the exception : Index was out of range.

I thinks this could be addressed with an additional check after the null check:

        if (response.Data.Length == 0)
        {
            Log.Debug("Empty response data from read.");
            return res;
        }