aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFileHandle.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2014-09-18 05:22:03 +0200
committerMax <post@wickenrode.com>2014-09-18 05:22:03 +0200
commitd1425fb1442d9594285dd3abf4aa19b9946e95c9 (patch)
tree0ed2be776b6ca541d9a3df4cabfc40154f138fcd /Source/SPFileHandle.m
parent22d2e2a62f994c1e11cf87c48cb0d526b9078b92 (diff)
downloadsequelpro-d1425fb1442d9594285dd3abf4aa19b9946e95c9.tar.gz
sequelpro-d1425fb1442d9594285dd3abf4aa19b9946e95c9.tar.bz2
sequelpro-d1425fb1442d9594285dd3abf4aa19b9946e95c9.zip
Fix #1983 (bz2 import breaks)
* Avoid a malloc(4) / free() and let the compiler figure that out * sizeof(pointer) != sizeof(memory area pointed to by pointer)
Diffstat (limited to 'Source/SPFileHandle.m')
-rw-r--r--Source/SPFileHandle.m11
1 files changed, 4 insertions, 7 deletions
diff --git a/Source/SPFileHandle.m b/Source/SPFileHandle.m
index 2f822c48..58350443 100644
--- a/Source/SPFileHandle.m
+++ b/Source/SPFileHandle.m
@@ -90,7 +90,7 @@
if (fileMode == O_RDONLY) {
int i, c;
- char *bzbuf = malloc(4);
+ char bzbuf[4];
const char *charFileMode = fileMode == O_WRONLY ? "wb" : "rb";
BZFILE *bzfile;
@@ -112,12 +112,9 @@
// indicate the Bzip version. Finally, the 4th byte should be a number between 1 and 9 that indicates
// the block size used.
- BOOL isBzip2 = (sizeof(bzbuf) == 4) &&
- ((bzbuf[0] == 'B') && (bzbuf[1] == 'Z') &&
- ((bzbuf[2] == 'h') || (bzbuf[2] == '0')) &&
- ((bzbuf[3] >= 0x31) && (bzbuf[3] <= 0x39)));
-
- free(bzbuf);
+ BOOL isBzip2 = ((bzbuf[0] == 'B') && (bzbuf[1] == 'Z')) &&
+ ((bzbuf[2] == 'h') || (bzbuf[2] == '0')) &&
+ ((bzbuf[3] >= 0x31) && (bzbuf[3] <= 0x39));
if (isBzip2) bzfile = BZ2_bzopen(path, charFileMode);