|
|
ca6c51 |
From: =?UTF-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <ovasik@redhat.com>
|
|
|
ca6c51 |
Date: Mon, 14 Sep 2015 09:47:05 +0200
|
|
|
ca6c51 |
Subject: [PATCH 5/7] fix segfault with nonexisting file with patternnames
|
|
|
ca6c51 |
(#567022)
|
|
|
ca6c51 |
|
|
|
ca6c51 |
diff --git a/src/copyin.c b/src/copyin.c
|
|
|
ca6c51 |
index 12bd27c..183b5b5 100644
|
|
|
ca6c51 |
--- a/src/copyin.c
|
|
|
ca6c51 |
+++ b/src/copyin.c
|
|
|
ca6c51 |
@@ -870,21 +870,24 @@ read_pattern_file ()
|
|
|
ca6c51 |
|
|
|
ca6c51 |
pattern_fp = fopen (pattern_file_name, "r");
|
|
|
ca6c51 |
if (pattern_fp == NULL)
|
|
|
ca6c51 |
- open_fatal (pattern_file_name);
|
|
|
ca6c51 |
- while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
|
|
|
ca6c51 |
- {
|
|
|
ca6c51 |
- if (new_num_patterns >= max_new_patterns)
|
|
|
ca6c51 |
- {
|
|
|
ca6c51 |
- max_new_patterns += 1;
|
|
|
ca6c51 |
- new_save_patterns = (char **)
|
|
|
ca6c51 |
- xrealloc ((char *) new_save_patterns,
|
|
|
ca6c51 |
- max_new_patterns * sizeof (char *));
|
|
|
ca6c51 |
- }
|
|
|
ca6c51 |
- new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
|
|
|
ca6c51 |
- ++new_num_patterns;
|
|
|
ca6c51 |
- }
|
|
|
ca6c51 |
- if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
|
|
|
ca6c51 |
- close_error (pattern_file_name);
|
|
|
ca6c51 |
+ open_error (pattern_file_name);
|
|
|
ca6c51 |
+ else
|
|
|
ca6c51 |
+ {
|
|
|
ca6c51 |
+ while (ds_fgetstr (pattern_fp, &pattern_name, '\n') != NULL)
|
|
|
ca6c51 |
+ {
|
|
|
ca6c51 |
+ if (new_num_patterns >= max_new_patterns)
|
|
|
ca6c51 |
+ {
|
|
|
ca6c51 |
+ max_new_patterns += 1;
|
|
|
ca6c51 |
+ new_save_patterns = (char **)
|
|
|
ca6c51 |
+ xrealloc ((char *) new_save_patterns,
|
|
|
ca6c51 |
+ max_new_patterns * sizeof (char *));
|
|
|
ca6c51 |
+ }
|
|
|
ca6c51 |
+ new_save_patterns[new_num_patterns] = xstrdup (pattern_name.ds_string);
|
|
|
ca6c51 |
+ ++new_num_patterns;
|
|
|
ca6c51 |
+ }
|
|
|
ca6c51 |
+ if (ferror (pattern_fp) || fclose (pattern_fp) == EOF)
|
|
|
ca6c51 |
+ close_error (pattern_file_name);
|
|
|
ca6c51 |
+ }
|
|
|
ca6c51 |
|
|
|
ca6c51 |
for (i = 0; i < num_patterns; ++i)
|
|
|
ca6c51 |
new_save_patterns[i] = save_patterns[i];
|