[gnumeric] glpk: check that the model is linear before writing bogus program



commit de58195f13ec49c632538b839bf8bd9c78910812
Author: Morten Welinder <terra gnome org>
Date:   Tue Jan 6 22:09:28 2015 -0500

    glpk: check that the model is linear before writing bogus program

 plugins/glpk/ChangeLog    |    5 +++++
 plugins/glpk/glpk-write.c |   10 ++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/plugins/glpk/ChangeLog b/plugins/glpk/ChangeLog
index d3ed8d7..159f71c 100644
--- a/plugins/glpk/ChangeLog
+++ b/plugins/glpk/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-06  Morten Welinder  <terra gnome org>
+
+       * glpk-write.c (glpk_create_program): Fail unless the problem is
+       linear.
+
 2014-09-25  Morten Welinder <terra gnome org>
 
        * Release 1.12.18
diff --git a/plugins/glpk/glpk-write.c b/plugins/glpk/glpk-write.c
index cc3230a..f3892ae 100644
--- a/plugins/glpk/glpk-write.c
+++ b/plugins/glpk/glpk-write.c
@@ -180,6 +180,16 @@ glpk_create_program (Sheet *sheet, GOIOContext *io_context,
 
        /* ---------------------------------------- */
 
+       if (sp->options.model_type != GNM_SOLVER_LP) {
+               g_set_error (err,
+                            go_error_invalid (),
+                            0,
+                            _("Only linear programs are handled."));
+               goto fail;
+       }
+
+       /* ---------------------------------------- */
+
        if (ssol) {
                unsigned ui;
                GSList *l;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]