Skip to content

Commit b135e91

Browse files
authored
Merge pull request #1233 from matejak/cov-6-9
Resolved some Coverity issues.
2 parents 9895db2 + 7df6475 commit b135e91

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/OVAL/probes/independent/textfilecontent.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ static SEXP_t *create_item(const char *path, const char *filename, char *pattern
221221
"text", OVAL_DATATYPE_STRING, substrs[0],
222222
NULL);
223223

224+
SEXP_string_free(se_filepath);
225+
SEXP_string_free(se_instance);
226+
224227
for (i = 1; i < substr_cnt; ++i) {
225228
probe_item_ent_add (item, "subexpression", NULL, r0 = SEXP_string_new (substrs[i], strlen (substrs[i])));
226229
SEXP_free (r0);
@@ -242,6 +245,8 @@ static int process_file(const char *prefix, const char *path, const char *filena
242245
char *whole_path = NULL, *whole_path_with_prefix = NULL;
243246
FILE *fp = NULL;
244247
struct stat st;
248+
char **substrs = NULL;
249+
int substr_cnt = 0;
245250

246251
// todo: move to probe_main()?
247252
#if defined USE_REGEX_PCRE
@@ -299,9 +304,6 @@ static int process_file(const char *prefix, const char *path, const char *filena
299304
char line[4096];
300305

301306
while (fgets(line, sizeof(line), fp) != NULL) {
302-
char **substrs;
303-
int substr_cnt;
304-
305307
substr_cnt = get_substrings(line, re, 1, &substrs);
306308
if (substr_cnt > 0) {
307309
int k;

src/OVAL/probes/independent/textfilecontent54.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ static int process_file(const char *prefix, const char *path, const char *file,
233233
struct pfdata *pfd = (struct pfdata *) arg;
234234
int ret = 0, path_len, file_len, cur_inst = 0, fd = -1, substr_cnt,
235235
buf_size = 0, buf_used = 0, ofs = 0, buf_inc = 4096;
236+
char **substrs = NULL;
236237
char *whole_path = NULL, *whole_path_with_prefix = NULL, *buf = NULL;
237238
SEXP_t *next_inst = NULL;
238239
struct stat st;
@@ -302,7 +303,6 @@ static int process_file(const char *prefix, const char *path, const char *file,
302303
buf[buf_used++] = '\0';
303304

304305
do {
305-
char **substrs;
306306
int want_instance;
307307

308308
next_inst = SEXP_number_newi_32(cur_inst + 1);

0 commit comments

Comments
 (0)