forked from len0rd/rockbox
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
This commit is contained in:
parent
f4943b90e6
commit
b22516f995
4 changed files with 20 additions and 8 deletions
|
|
@ -30,15 +30,21 @@ BootloaderInstallIpod::BootloaderInstallIpod(QObject *parent)
|
|||
{
|
||||
(void)parent;
|
||||
// initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher.
|
||||
ipod_sectorbuf = NULL;
|
||||
ipod_alloc_buffer(&ipod_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(ipod_sectorbuf == NULL)
|
||||
ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallIpod::~BootloaderInstallIpod()
|
||||
{
|
||||
if(ipod_sectorbuf)
|
||||
if(ipod_sectorbuf) {
|
||||
free(ipod_sectorbuf);
|
||||
ipod_sectorbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue