mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
int ipod_verbose = 0;
|
int ipod_verbose = 0;
|
||||||
|
|
||||||
unsigned char* ipod_sectorbuf;
|
unsigned char* ipod_sectorbuf = NULL;
|
||||||
|
|
||||||
/* The following string appears at the start of the firmware partition */
|
/* The following string appears at the start of the firmware partition */
|
||||||
static const char *apple_stop_sign = "{{~~ /-----\\ "\
|
static const char *apple_stop_sign = "{{~~ /-----\\ "\
|
||||||
|
|
|
@ -30,15 +30,21 @@ BootloaderInstallIpod::BootloaderInstallIpod(QObject *parent)
|
||||||
{
|
{
|
||||||
(void)parent;
|
(void)parent;
|
||||||
// initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher.
|
// initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher.
|
||||||
ipod_sectorbuf = NULL;
|
// The buffer itself is only present once, so make sure to not allocate
|
||||||
ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
|
// 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()
|
BootloaderInstallIpod::~BootloaderInstallIpod()
|
||||||
{
|
{
|
||||||
if(ipod_sectorbuf)
|
if(ipod_sectorbuf) {
|
||||||
free(ipod_sectorbuf);
|
free(ipod_sectorbuf);
|
||||||
|
ipod_sectorbuf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,21 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent)
|
||||||
(void)parent;
|
(void)parent;
|
||||||
// initialize sector buffer. sansa_sectorbuf is instantiated by
|
// initialize sector buffer. sansa_sectorbuf is instantiated by
|
||||||
// sansapatcher.
|
// sansapatcher.
|
||||||
sansa_sectorbuf = NULL;
|
// The buffer itself is only present once, so make sure to not allocate
|
||||||
sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
|
// 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()
|
BootloaderInstallSansa::~BootloaderInstallSansa()
|
||||||
{
|
{
|
||||||
if(sansa_sectorbuf)
|
if(sansa_sectorbuf) {
|
||||||
free(sansa_sectorbuf);
|
free(sansa_sectorbuf);
|
||||||
|
sansa_sectorbuf = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ int sansa_verbose = 0;
|
||||||
and initialise it with sansa_alloc_buf() in main().
|
and initialise it with sansa_alloc_buf() in main().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned char* sansa_sectorbuf;
|
unsigned char* sansa_sectorbuf = NULL;
|
||||||
|
|
||||||
static off_t filesize(int fd) {
|
static off_t filesize(int fd) {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue