rbutil: Fix crash on sansapatcher access.

We now initialize sectorbuf explicitly, and there are situation where it
wasn't initialized explicitly.

Change-Id: I35516a1fa7326c0861885ffa058737de19285c2c
This commit is contained in:
Dominik Riebeling 2022-03-12 21:07:07 +01:00
parent 1ff11b627b
commit 5c7b0e071f

View file

@ -43,11 +43,7 @@ BootloaderInstallSansa::~BootloaderInstallSansa()
*/
bool BootloaderInstallSansa::install(void)
{
// initialize sector buffer. The sector buffer is part of the sansa_t
// structure, so a second instance of this class will have its own buffer.
if(sansa.sectorbuf == nullptr) {
sansa_alloc_buffer(&sansa, BUFFER_SIZE);
}
sansaInitialize(&sansa);
if(sansa.sectorbuf == nullptr) {
emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR);
@ -236,6 +232,12 @@ BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void)
bool BootloaderInstallSansa::sansaInitialize(struct sansa_t *sansa)
{
// initialize sector buffer. The sector buffer is part of the sansa_t
// structure, so a second instance of this class will have its own buffer.
if(sansa->sectorbuf == nullptr) {
sansa_alloc_buffer(sansa, BUFFER_SIZE);
}
if(!m_blfile.isEmpty()) {
QString devicename = Utils::resolveDevicename(m_blfile);
if(devicename.isEmpty()) {