Skip to content

Commit d2eaa97

Browse files
authored
Merge pull request #6 from tmfink-juniper/juniper-contrib
Fix some compiler warnings and resource leaks
2 parents c05c1c5 + 2f435da commit d2eaa97

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2017-11-28: Travis Finkenauer <tmfink@juniper.net>:
2+
3+
* edit_dist.c: Include edit_dist.h to pick up forward declaration of
4+
edit_distn().
5+
* engine.cpp (display_result): Initialize before use in case of
6+
uncaught exception.
7+
* filedata.h (class Filedata): Avoid unused variable warning.
8+
* find-file-size.c: Add function prototypes for find_dev_size() and
9+
find_file_size() to keep compiler happy.
10+
* fuzzy.c (fuzzy_hash_file): Avoid a memory leak.
11+
* match.cpp (sig_file_close): Fix reversed logic to close handle.
12+
113
2017-06-01: Tsukasa OI <floss_ssdeep@irq.a4lg.com>:
214

315
* fuzzy.c, sum_table.h: Added many optimizations

edit_dist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ int edit_distn(const char *s1, size_t s1len, const char *s2, size_t s2len) {
4747
#include <stdio.h>
4848
#include <stdlib.h>
4949
#include <string.h>
50+
#include "edit_dist.h"
5051

5152
#define HELLOWORLD "Hello World!"
5253

engine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
bool display_result(state *s, const TCHAR * fn, const char * sum) {
1010
// Only spend the extra time to make a Filedata object if we need to
1111
if (MODE(mode_match_pretty) or MODE(mode_match) or MODE(mode_directory)) {
12-
Filedata * f;
12+
Filedata * f = NULL;
1313

1414
try {
1515
f = new Filedata(fn, sum);

filedata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Filedata
5252
~Filedata() { if (m_filename) { free(m_filename); } }
5353

5454
private:
55-
Filedata(const Filedata &other) { assert(false); /* never copy */ }
55+
Filedata(const Filedata &other) { (void) other; assert(false); /* never copy */ }
5656

5757
std::set<Filedata *> * m_cluster;
5858

find-file-size.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
#include "main.h"
99

10+
// Prototypes
11+
off_t find_file_size(FILE *f);
12+
off_t find_dev_size(int fd, int blk_size);
13+
14+
1015
#ifndef _WIN32
1116

1217
// Return the size, in bytes of an open file stream. On error, return 0

fuzzy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ int fuzzy_hash_file(FILE *handle, /*@out@*/ char *result)
583583
if (status == 0)
584584
{
585585
if (fseeko(handle, fpos, SEEK_SET) < 0)
586-
return -1;
586+
status = -1;
587587
}
588588
fuzzy_free(ctx);
589589
return status;

match.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ bool sig_file_close(state *s)
127127

128128
free(s->known_fn);
129129

130-
if (s->known_handle != NULL)
130+
if (s->known_handle == NULL)
131131
return true;
132132

133133
if (fclose(s->known_handle))

0 commit comments

Comments
 (0)