summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-05-01 21:35:06 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-05-01 21:35:06 +0000
commitb22516f995ef4a448251b883b0737d4aa0abdb84 (patch)
treee022040257aaf8f7e9fbc4b004acdea7e1d55ca9 /rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
parentf4943b90e69e75cc2301238969520914553d7ae5 (diff)
downloadrockbox-b22516f995ef4a448251b883b0737d4aa0abdb84.tar.gz
rockbox-b22516f995ef4a448251b883b0737d4aa0abdb84.tar.bz2
rockbox-b22516f995ef4a448251b883b0737d4aa0abdb84.zip
Make sure the global buffers for ipodpatcher and sansapatcher get allocated and freed only once. Fixes segfaults when the bootloader install class was instanciated multiple times.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20835 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallsansa.cpp')
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallsansa.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
index aab298ce95..19750446f6 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
@@ -30,15 +30,21 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent)
(void)parent;
// initialize sector buffer. sansa_sectorbuf is instantiated by
// sansapatcher.
- sansa_sectorbuf = NULL;
- sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
+ // The buffer itself is only present once, so make sure to not allocate
+ // it if it was already allocated. The application needs to take care
+ // no concurrent (i.e. multiple objects of this class running) requests
+ // are done.
+ if(sansa_sectorbuf == NULL)
+ sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
}
BootloaderInstallSansa::~BootloaderInstallSansa()
{
- if(sansa_sectorbuf)
+ if(sansa_sectorbuf) {
free(sansa_sectorbuf);
+ sansa_sectorbuf = NULL;
+ }
}