[gnumeric] Cppcheck: fixes from Mario Rugiero <mrugiero gmail com>
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Cppcheck: fixes from Mario Rugiero <mrugiero gmail com>
- Date: Fri, 13 Dec 2013 02:00:18 +0000 (UTC)
commit 9517c2ebd058ac0aac7cb336ae08ac7c29e6ebcb
Author: Morten Welinder <terra gnome org>
Date: Thu Dec 12 20:59:39 2013 -0500
Cppcheck: fixes from Mario Rugiero <mrugiero gmail com>
ChangeLog | 5 ++++
NEWS | 3 ++
plugins/excel/ms-excel-read.c | 4 ++-
plugins/excelplugins/ExcelTestModule.c | 2 +-
src/dialogs/dialog-analysis-tool-chi-squared.c | 3 ++
src/dialogs/dialog-analysis-tool-frequency.c | 3 ++
src/dialogs/dialog-analysis-tool-kaplan-meier.c | 3 ++
src/dialogs/dialog-analysis-tool-normality.c | 3 ++
src/dialogs/dialog-analysis-tool-one-mean.c | 3 ++
src/dialogs/dialog-analysis-tool-sign-test.c | 6 ++++
src/dialogs/dialog-analysis-tools.c | 30 +++++++++++++++++++++++
src/dialogs/dialog-scenarios.c | 3 ++
src/sf-bessel.c | 5 ++-
13 files changed, 69 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f0bb864..b8f9dc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-12-12 Mario Rugiero <mrugiero gmail com>
+
+ * */*.c: Fix some leaks and null dereferences pointed out by
+ cppcheck.
+
2013-12-12 Morten Welinder <terra gnome org>
* src/parser.y (array_row): Avoid overrunning string when multiple
diff --git a/NEWS b/NEWS
index e0c0444..883dbf4 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ Gnumeric 1.12.10
Andreas:
* Fix handling of dashes on ODF import. [#719509]
+Mario Rugiero:
+ * Fix leaks. [#720306]
+
Morten:
* Extend POCHHAMMER to negative values.
* Improve accuracy of BETA and BETALN.
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index b080649..e12fc20 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -1614,11 +1614,13 @@ static void
excel_read_FONT (BiffQuery *q, GnmXLImporter *importer)
{
MsBiffVersion const ver = importer->ver;
- ExcelFont *fd = g_new (ExcelFont, 1);
+ ExcelFont *fd;
guint16 data;
guint8 data1;
XL_CHECK_CONDITION (q->length >= 4);
+
+ fd = g_new (ExcelFont, 1);
fd->height = GSF_LE_GET_GUINT16 (q->data + 0);
data = GSF_LE_GET_GUINT16 (q->data + 2);
fd->italic = (data & 0x2) == 0x2;
diff --git a/plugins/excelplugins/ExcelTestModule.c b/plugins/excelplugins/ExcelTestModule.c
index 26a57ba..9b800e0 100644
--- a/plugins/excelplugins/ExcelTestModule.c
+++ b/plugins/excelplugins/ExcelTestModule.c
@@ -110,8 +110,8 @@ static void destruct_xloper(XLOPER*x){
case xltypeInt: break;
default: unsupported_xloper_type(x);
}
+ x->xltype=xltypeNil;
}
- x->xltype=xltypeNil;
}
static void copy_construct_xloper(XLOPER*x,const XLOPER*y){
diff --git a/src/dialogs/dialog-analysis-tool-chi-squared.c b/src/dialogs/dialog-analysis-tool-chi-squared.c
index f8608cd..aff98d0 100644
--- a/src/dialogs/dialog-analysis-tool-chi-squared.c
+++ b/src/dialogs/dialog-analysis-tool-chi-squared.c
@@ -222,7 +222,10 @@ dialog_chi_square_tool (WBCGtk *wbcg, Sheet *sheet, gboolean independence)
NULL,
G_CALLBACK (chi_squared_tool_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
if (independence)
type ="test-of-independence";
diff --git a/src/dialogs/dialog-analysis-tool-frequency.c b/src/dialogs/dialog-analysis-tool-frequency.c
index 65e48f0..99c5d5c 100644
--- a/src/dialogs/dialog-analysis-tool-frequency.c
+++ b/src/dialogs/dialog-analysis-tool-frequency.c
@@ -261,7 +261,10 @@ dialog_frequency_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (frequency_tool_ok_clicked_cb), NULL,
G_CALLBACK (frequency_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->predetermined_button = tool_setup_update
(&state->base, "pre_determined_button",
diff --git a/src/dialogs/dialog-analysis-tool-kaplan-meier.c b/src/dialogs/dialog-analysis-tool-kaplan-meier.c
index 93f7f41..15e267c 100644
--- a/src/dialogs/dialog-analysis-tool-kaplan-meier.c
+++ b/src/dialogs/dialog-analysis-tool-kaplan-meier.c
@@ -629,7 +629,10 @@ dialog_kaplan_meier_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (kaplan_meier_tool_ok_clicked_cb), NULL,
G_CALLBACK (kaplan_meier_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
diff --git a/src/dialogs/dialog-analysis-tool-normality.c b/src/dialogs/dialog-analysis-tool-normality.c
index 95c3e27..8974438 100644
--- a/src/dialogs/dialog-analysis-tool-normality.c
+++ b/src/dialogs/dialog-analysis-tool-normality.c
@@ -204,7 +204,10 @@ dialog_normality_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (normality_tool_ok_clicked_cb), NULL,
G_CALLBACK (normality_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = tool_setup_update
diff --git a/src/dialogs/dialog-analysis-tool-one-mean.c b/src/dialogs/dialog-analysis-tool-one-mean.c
index 6fbb742..57d4d26 100644
--- a/src/dialogs/dialog-analysis-tool-one-mean.c
+++ b/src/dialogs/dialog-analysis-tool-one-mean.c
@@ -228,7 +228,10 @@ dialog_one_mean_test_tool (WBCGtk *wbcg, Sheet *sheet)
NULL,
G_CALLBACK (one_mean_test_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = tool_setup_update
diff --git a/src/dialogs/dialog-analysis-tool-sign-test.c b/src/dialogs/dialog-analysis-tool-sign-test.c
index 9c70930..f91294c 100644
--- a/src/dialogs/dialog-analysis-tool-sign-test.c
+++ b/src/dialogs/dialog-analysis-tool-sign-test.c
@@ -261,7 +261,10 @@ dialog_sign_test_two_tool (WBCGtk *wbcg, Sheet *sheet, signtest_type type)
NULL,
G_CALLBACK (sign_test_two_tool_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = tool_setup_update
@@ -406,7 +409,10 @@ dialog_sign_test_tool (WBCGtk *wbcg, Sheet *sheet, signtest_type type)
NULL,
G_CALLBACK (sign_test_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = tool_setup_update
diff --git a/src/dialogs/dialog-analysis-tools.c b/src/dialogs/dialog-analysis-tools.c
index 88eaa05..36f6212 100644
--- a/src/dialogs/dialog-analysis-tools.c
+++ b/src/dialogs/dialog-analysis-tools.c
@@ -1234,7 +1234,10 @@ dialog_descriptive_stat_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (cb_desc_stat_tool_ok_clicked), NULL,
G_CALLBACK (desc_stat_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->summary_stats_button = go_gtk_builder_get_widget
(state->base.gui, "summary_stats_button");
@@ -1616,7 +1619,10 @@ dialog_ttest_tool (WBCGtk *wbcg, Sheet *sheet, ttest_type test)
G_CALLBACK (ttest_tool_ok_clicked_cb), NULL,
G_CALLBACK (ttest_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
state->paired_button = go_gtk_builder_get_widget (state->base.gui, "paired-button");
state->unpaired_button = go_gtk_builder_get_widget (state->base.gui, "unpaired-button");
@@ -1803,7 +1809,10 @@ dialog_ftest_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (ftest_tool_ok_clicked_cb), NULL,
G_CALLBACK (ftest_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = go_gtk_builder_get_widget (state->base.gui, "one_alpha");
float_to_entry (GTK_ENTRY (state->alpha_entry), 0.05);
@@ -2058,7 +2067,10 @@ dialog_sampling_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (sampling_tool_ok_clicked_cb), NULL,
G_CALLBACK (sampling_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->periodic_button = go_gtk_builder_get_widget (state->base.gui, "periodic-button");
state->random_button = go_gtk_builder_get_widget (state->base.gui, "random-button");
@@ -2417,7 +2429,10 @@ dialog_regression_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (regression_tool_ok_clicked_cb), NULL,
G_CALLBACK (regression_tool_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
state->confidence_entry = go_gtk_builder_get_widget (state->base.gui, "confidence-entry");
float_to_entry (GTK_ENTRY (state->confidence_entry), 0.95);
@@ -2727,7 +2742,10 @@ dialog_exp_smoothing_tool (WBCGtk *wbcg, Sheet *sheet)
NULL,
G_CALLBACK (exp_smoothing_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->damping_fact_entry = go_gtk_builder_get_widget (state->base.gui,
"damping-fact-spin");
@@ -3097,7 +3115,10 @@ dialog_average_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (average_tool_ok_clicked_cb), NULL,
G_CALLBACK (average_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->interval_entry = go_gtk_builder_get_widget (state->base.gui, "interval-entry");
int_to_entry (GTK_ENTRY (state->interval_entry), 3);
@@ -3364,7 +3385,10 @@ dialog_histogram_tool (WBCGtk *wbcg, Sheet *sheet)
G_CALLBACK (histogram_tool_ok_clicked_cb), NULL,
G_CALLBACK (histogram_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->predetermined_button = GTK_WIDGET (go_gtk_builder_get_widget
(state->base.gui,
@@ -3543,7 +3567,10 @@ dialog_anova_single_factor_tool (WBCGtk *wbcg, Sheet *sheet)
NULL,
G_CALLBACK (anova_single_tool_update_sensitivity_cb),
0))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = go_gtk_builder_get_widget (state->base.gui,
"alpha-entry");
@@ -3772,7 +3799,10 @@ dialog_anova_two_factor_tool (WBCGtk *wbcg, Sheet *sheet)
NULL,
G_CALLBACK (anova_two_factor_tool_update_sensitivity_cb),
GNM_EE_SINGLE_RANGE))
+ {
+ g_free(state);
return 0;
+ }
state->alpha_entry = go_gtk_builder_get_widget (state->base.gui,
"alpha-entry");
diff --git a/src/dialogs/dialog-scenarios.c b/src/dialogs/dialog-scenarios.c
index 3117506..94d800d 100644
--- a/src/dialogs/dialog-scenarios.c
+++ b/src/dialogs/dialog-scenarios.c
@@ -399,7 +399,10 @@ dialog_scenario_add (WBCGtk *wbcg)
G_CALLBACK (scenario_add_ok_clicked_cb), NULL,
G_CALLBACK (scenario_add_update_sensitivity_cb),
GNM_EE_SHEET_OPTIONAL))
+ {
+ g_free (state);
return;
+ }
state->name_entry = go_gtk_builder_get_widget (state->base.gui, "name_entry");
if (state->name_entry == NULL)
diff --git a/src/sf-bessel.c b/src/sf-bessel.c
index 119baa4..37c803f 100644
--- a/src/sf-bessel.c
+++ b/src/sf-bessel.c
@@ -1809,9 +1809,10 @@ static gnm_float bessel_y(gnm_float x, gnm_float alpha)
#endif
Y_bessel(&x, &alpha, &nb, by, &ncalc);
if(ncalc != nb) {/* error input */
- if(ncalc == -1)
+ if(ncalc == -1) {
+ free(by);
return gnm_pinf;
- else if(ncalc < -1)
+ } else if(ncalc < -1)
MATHLIB_WARNING4(("bessel_y(%" GNM_FORMAT_g "): ncalc (=%ld) != nb (=%ld); alpha=%" GNM_FORMAT_g
". Arg. out of range?\n"),
x, ncalc, nb, alpha);
else /* ncalc >= 0 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]