[grisbi-cvs] grisbi/src gsb_data_account.c, 1.106, 1.107 gsb_data_payee.c, 1.54, 1.55 gsb_real.c, 1.79, 1.80 utils_dates.c, 1.68, 1.69
Mathias Lorente
m-lorente at users.sourceforge.net
Thu May 13 20:38:13 CEST 2010
Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25823/src
Modified Files:
gsb_data_account.c gsb_data_payee.c gsb_real.c utils_dates.c
Log Message:
Hunt memory leak. Work in progress...
Index: gsb_real.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_real.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- gsb_real.c 6 May 2010 19:47:14 -0000 1.79
+++ gsb_real.c 13 May 2010 18:38:10 -0000 1.80
@@ -378,13 +378,14 @@
gint8 sign = 0;
gint8 dot_position = -1;
const gchar *p = string;
+ gboolean success = FALSE;
if ( !string)
return error_real;
mts_len = mon_thousands_sep
- ? strlen ( mon_thousands_sep )
- : 0;
+ ? strlen ( mon_thousands_sep )
+ : 0;
mdp_len = mon_decimal_point ? strlen ( mon_decimal_point ) : 0;
if ( mon_thousands_sep )
@@ -396,9 +397,9 @@
}
decimal_chars = g_strconcat(default_decimal_char_dot,
- default_decimal_char_comma,
- mon_decimal_point,
- NULL);
+ default_decimal_char_comma,
+ mon_decimal_point,
+ NULL);
space_chars = g_strconcat(" ", mon_thousands_sep, NULL);
for ( ; ; )
@@ -408,24 +409,24 @@
mantissa *= 10;
mantissa += ( *p - '0' );
if ( mantissa > G_MAXLONG )
- return error_real;
+ {
+ break;
+ }
if ( sign == 0 ) sign = 1; // no sign found yet ==> positive
++nb_digits;
++p;
}
else if ( *p == 0 ) // terminal zero
{
- gsb_real result;
- result.mantissa = sign * mantissa;
- result.exponent = ( dot_position >= 0 )
- ? nb_digits - dot_position
- : 0;
- return result;
+ success = TRUE;
+ break;
}
else if ( decimal_chars && strchr ( decimal_chars, *p ) )
{
if ( dot_position >= 0 ) // already found a decimal separator
- return error_real;
+ {
+ break;
+ }
dot_position = nb_digits;
p = g_utf8_find_next_char ( p, NULL );
}
@@ -437,25 +438,42 @@
else if ( strchr ( negative_chars, *p ) )
{
if ( sign != 0 ) // sign already set
- return error_real;
+ {
+ break;
+ }
sign = -1;
++p;
}
else if ( strchr ( positive_chars, *p ) )
{
if ( sign != 0 ) // sign already set
- return error_real;
+ {
+ break;
+ }
sign = 1;
++p;
}
else // unknown char ==> error
{
- return error_real;
+ break;
}
}
- /* Free memory */
- g_free ( decimal_chars );
- g_free ( space_chars );
+ /* Free memory */
+ g_free ( decimal_chars );
+ g_free ( space_chars );
+ if (success == TRUE)
+ {
+ gsb_real result;
+ result.mantissa = sign * mantissa;
+ result.exponent = ( dot_position >= 0 )
+ ? nb_digits - dot_position
+ : 0;
+ return result;
+ }
+ else
+ {
+ return error_real;
+ }
}
Index: utils_dates.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_dates.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- utils_dates.c 5 Apr 2010 21:24:53 -0000 1.68
+++ utils_dates.c 13 May 2010 18:38:11 -0000 1.69
@@ -66,12 +66,13 @@
{
if (!last_date)
{
- GDate *date;
- gchar date_str[SIZEOF_FORMATTED_STRING_DATE];
+ GDate *date;
+ gchar date_str[SIZEOF_FORMATTED_STRING_DATE];
- date = gdate_today();
- g_date_strftime ( date_str, SIZEOF_FORMATTED_STRING_DATE, "%x", date );
- gsb_date_set_last_date (date_str);
+ date = gdate_today();
+ g_date_strftime ( date_str, SIZEOF_FORMATTED_STRING_DATE, "%x", date );
+ gsb_date_set_last_date (date_str);
+ g_date_free( date );
}
return (last_date);
}
@@ -446,6 +447,7 @@
else
{
g_date_free ( date );
+ g_strfreev ( tab_date );
return NULL;
}
break;
@@ -458,6 +460,7 @@
else
{
g_date_free ( date );
+ g_strfreev ( tab_date );
return NULL;
}
break;
@@ -484,18 +487,20 @@
else
{
g_date_free ( date );
+ g_strfreev ( tab_date );
return NULL;
}
break;
default:
g_printerr ( ">> Unknown format '%c'\n", date_tokens [ i ] );
g_date_free ( date );
+ g_strfreev ( tab_date );
return NULL;
break;
}
}
/* comment for random crash. Memory allocation problem in split_unique_datefield () */
- //~ g_strfreev ( tab_date );
+ g_strfreev ( tab_date );
/* need here to check if the date is valid, else an error occurs when
* write for example only 31, and the current month has only 30 days... */
Index: gsb_data_payee.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_payee.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- gsb_data_payee.c 4 May 2010 12:27:53 -0000 1.54
+++ gsb_data_payee.c 13 May 2010 18:38:10 -0000 1.55
@@ -744,19 +744,22 @@
* we work with empty_payee */
if (!payee
- &&
- !gsb_data_transaction_get_split_of_transaction (transaction_number)
- &&
- gsb_data_transaction_get_contra_transaction_number (transaction_number) == 0)
- payee = empty_payee;
+ &&
+ !gsb_data_transaction_get_split_of_transaction (transaction_number)
+ &&
+ gsb_data_transaction_get_contra_transaction_number (transaction_number) == 0)
+ payee = empty_payee;
- payee -> payee_nb_transactions --;
- payee -> payee_balance = gsb_real_sub ( payee -> payee_balance,
- gsb_data_transaction_get_adjusted_amount_for_currency ( transaction_number,
- payee_tree_currency (), -1));
+ if (payee)
+ {
+ payee -> payee_nb_transactions --;
+ payee -> payee_balance = gsb_real_sub ( payee -> payee_balance,
+ gsb_data_transaction_get_adjusted_amount_for_currency ( transaction_number,
+ payee_tree_currency (), -1));
- if ( !payee -> payee_nb_transactions ) /* Cope with float errors */
- payee -> payee_balance = null_real;
+ if ( !payee -> payee_nb_transactions ) /* Cope with float errors */
+ payee -> payee_balance = null_real;
+ }
}
Index: gsb_data_account.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_account.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- gsb_data_account.c 8 May 2010 05:54:13 -0000 1.106
+++ gsb_data_account.c 13 May 2010 18:38:10 -0000 1.107
@@ -226,8 +226,7 @@
last_number = gsb_data_account_max_number ();
/* we have to append the account first because some functions later will
* look for that account */
- list_accounts = g_slist_append ( list_accounts,
- account );
+ list_accounts = g_slist_append ( list_accounts, account );
/* set the base */
account -> account_number = last_number + 1;
More information about the cvs
mailing list