[Gpredict-svn] SF.net SVN: gpredict:[839] trunk
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <aa...@us...> - 2011-07-02 19:55:22
|
Revision: 839
http://gpredict.svn.sourceforge.net/gpredict/?rev=839&view=rev
Author: aa1vs
Date: 2011-07-02 19:55:16 +0000 (Sat, 02 Jul 2011)
Log Message:
-----------
Add check on mod->grid allocation.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/gtk-sat-module.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-07-02 15:51:44 UTC (rev 838)
+++ trunk/ChangeLog 2011-07-02 19:55:16 UTC (rev 839)
@@ -3,7 +3,10 @@
* src/gtk-sat-map.c
Add check on satellite map object allocation.
+ * src/gtk-sat-module.c
+ Add check on mod->grid allocation.
+
2011-06-29 Charles Suprin <hamaa1vs at gmail.com>
* src/tle-update.c
Modified: trunk/src/gtk-sat-module.c
===================================================================
--- trunk/src/gtk-sat-module.c 2011-07-02 15:51:44 UTC (rev 838)
+++ trunk/src/gtk-sat-module.c 2011-07-02 19:55:16 UTC (rev 839)
@@ -619,13 +619,19 @@
/* number of views: we have five numbers per view (type,left,right,top,bottom) */
module->nviews = length / 5;
module->grid = g_try_new0 (gint, length);
-
- /* FIXME: we should check module->grid != NULL */
-
- /* convert chars to integers */
- for (i = 0; i < length; i++) {
- module->grid[i] = (gint) g_ascii_strtoll (buffv[i], NULL, 0);
- //g_print ("%d: %s => %d\n", i, buffv[i], module->grid[i]);
+
+ /* if we cannot allocate memory for the grid zero the views out and log */
+ if ( module->grid != NULL ) {
+ /* convert chars to integers */
+ for (i = 0; i < length; i++) {
+ module->grid[i] = (gint) g_ascii_strtoll (buffv[i], NULL, 0);
+ //g_print ("%d: %s => %d\n", i, buffv[i], module->grid[i]);
+ }
+ } else {
+ module->nviews = 0;
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Unable to allocate memory for grid."),
+ __FUNCTION__);
}
g_strfreev (buffv);
@@ -1566,8 +1572,7 @@
guint i;
guint xmax = 0;
guint ymax = 0;
-
-
+
for (i = 0; i < module->nviews; i++) {
xmax = MAX(xmax,module->grid[5*i+2]);
ymax = MAX(ymax,module->grid[5*i+4]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|