summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/io/inkjar.cpp19
-rw-r--r--src/io/streamtest.cpp8
-rw-r--r--src/trace/imagemap.cpp8
3 files changed, 23 insertions, 12 deletions
diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp
index c238aba36..20b164b99 100644
--- a/src/io/inkjar.cpp
+++ b/src/io/inkjar.cpp
@@ -139,16 +139,18 @@ bool JarFile::read_signature()
#endif
if (signature == 0x08074b50) {
- //skip data descriptor
- bytes = (guint8 *)malloc(sizeof(guint8) * 12);
- if (!read(bytes, 12)) {
- g_free(bytes);
- return false;
- }
+ //skip data descriptor
+ bytes = (guint8 *)g_malloc(sizeof(guint8) * 12);
+ if (!read(bytes, 12)) {
+ g_free(bytes);
+ return false;
+ } else {
+ g_free(bytes);
+ }
} else if (signature == 0x02014b50 || signature == 0x04034b50) {
- return true;
+ return true;
} else {
- return false;
+ return false;
}
return false;
}
@@ -214,6 +216,7 @@ GByteArray *JarFile::get_next_file_contents()
if (_last_filename != NULL)
g_free(_last_filename);
_last_filename = NULL;
+ g_free(bytes);
return NULL;
}
diff --git a/src/io/streamtest.cpp b/src/io/streamtest.cpp
index b25ef43f0..2030e6a85 100644
--- a/src/io/streamtest.cpp
+++ b/src/io/streamtest.cpp
@@ -219,13 +219,15 @@ int main(int argc, char **argv)
// create temp files somewhere else instead of current dir
// TODO: clean them up too
char * testpath = strdup("/tmp/streamtest-XXXXXX");
- testpath = mkdtemp(testpath);
- if (!testpath)
+ char * testpath2;
+ testpath2 = mkdtemp(testpath);
+ free(testpath);
+ if (!testpath2)
{
perror("mkdtemp");
return 1;
}
- if (chdir(testpath))
+ if (chdir(testpath2))
{
perror("chdir");
return 1;
diff --git a/src/trace/imagemap.cpp b/src/trace/imagemap.cpp
index a9ad9b9c8..c5a6bc2b5 100644
--- a/src/trace/imagemap.cpp
+++ b/src/trace/imagemap.cpp
@@ -78,10 +78,16 @@ GrayMap *GrayMapCreate(int width, int height)
me->height = height;
me->pixels = (unsigned long *)
malloc(sizeof(unsigned long) * width * height);
+ if (!me->pixels)
+ {
+ free(me);
+ return NULL;
+ }
me->rows = (unsigned long **)
malloc(sizeof(unsigned long *) * height);
- if (!me->pixels || !me->rows)
+ if (!me->rows)
{
+ free(me->pixels);
free(me);
return NULL;
}