summaryrefslogtreecommitdiff
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
parentf4943b90e69e75cc2301238969520914553d7ae5 (diff)
downloadrockbox-b22516f995ef4a448251b883b0737d4aa0abdb84.tar.gz
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
-rw-r--r--rbutil/ipodpatcher/ipodpatcher.c2
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallipod.cpp12
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallsansa.cpp12
-rw-r--r--rbutil/sansapatcher/sansapatcher.c2
4 files changed, 20 insertions, 8 deletions
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c
index 73467dea34..dd650506a1 100644
--- a/rbutil/ipodpatcher/ipodpatcher.c
+++ b/rbutil/ipodpatcher/ipodpatcher.c
@@ -50,7 +50,7 @@
50 50
51int ipod_verbose = 0; 51int ipod_verbose = 0;
52 52
53unsigned char* ipod_sectorbuf; 53unsigned char* ipod_sectorbuf = NULL;
54 54
55/* The following string appears at the start of the firmware partition */ 55/* The following string appears at the start of the firmware partition */
56static const char *apple_stop_sign = "{{~~ /-----\\ "\ 56static const char *apple_stop_sign = "{{~~ /-----\\ "\
diff --git a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
index e4a70e0cd6..f622225f22 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp
@@ -30,15 +30,21 @@ BootloaderInstallIpod::BootloaderInstallIpod(QObject *parent)
30{ 30{
31 (void)parent; 31 (void)parent;
32 // initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher. 32 // initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher.
33 ipod_sectorbuf = NULL; 33 // The buffer itself is only present once, so make sure to not allocate
34 ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE); 34 // it if it was already allocated. The application needs to take care
35 // no concurrent (i.e. multiple objects of this class running) requests
36 // are done.
37 if(ipod_sectorbuf == NULL)
38 ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
35} 39}
36 40
37 41
38BootloaderInstallIpod::~BootloaderInstallIpod() 42BootloaderInstallIpod::~BootloaderInstallIpod()
39{ 43{
40 if(ipod_sectorbuf) 44 if(ipod_sectorbuf) {
41 free(ipod_sectorbuf); 45 free(ipod_sectorbuf);
46 ipod_sectorbuf = NULL;
47 }
42} 48}
43 49
44 50
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)
30 (void)parent; 30 (void)parent;
31 // initialize sector buffer. sansa_sectorbuf is instantiated by 31 // initialize sector buffer. sansa_sectorbuf is instantiated by
32 // sansapatcher. 32 // sansapatcher.
33 sansa_sectorbuf = NULL; 33 // The buffer itself is only present once, so make sure to not allocate
34 sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE); 34 // it if it was already allocated. The application needs to take care
35 // no concurrent (i.e. multiple objects of this class running) requests
36 // are done.
37 if(sansa_sectorbuf == NULL)
38 sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
35} 39}
36 40
37 41
38BootloaderInstallSansa::~BootloaderInstallSansa() 42BootloaderInstallSansa::~BootloaderInstallSansa()
39{ 43{
40 if(sansa_sectorbuf) 44 if(sansa_sectorbuf) {
41 free(sansa_sectorbuf); 45 free(sansa_sectorbuf);
46 sansa_sectorbuf = NULL;
47 }
42} 48}
43 49
44 50
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index 8d3191901a..015e5cbaf2 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -47,7 +47,7 @@ int sansa_verbose = 0;
47 and initialise it with sansa_alloc_buf() in main(). 47 and initialise it with sansa_alloc_buf() in main().
48*/ 48*/
49 49
50unsigned char* sansa_sectorbuf; 50unsigned char* sansa_sectorbuf = NULL;
51 51
52static off_t filesize(int fd) { 52static off_t filesize(int fd) {
53 struct stat buf; 53 struct stat buf;