Commits

Shlomi Fish  committed 35aa2fe

Fix a valgrind warning on some invalid inputs.

  • Participants
  • Parent commits 9395ba3

Comments (0)

Files changed (5)

File fc-solve/source/DONE.txt

 pointers games.
 ** Test suite now passes on 32-bit architectures.
 
+* Investigate the valgrind errors on processing layouts with 7 stacks
+instead of 8 such as:
+
+--------------------------------------------------------
+5H QH 3C AC 3H 4H QD 4C
+QC 9S 6H 9H 3S KS 3D 2C
+5D 2S JC 5C JH 6D AS 9C
+2D KD TH TC TD 8D 8C
+7H JS KH TS KC 7C QS
+AH 5S 6S AD 8H JD 4S
+7S 6C 7D 4D 8S 9D 2H
+--------------------------------------------------------
 

File fc-solve/source/TODO.txt

 Pressing
 --------
 
-* Investigate the valgrind errors on processing layouts with 7 stacks
-instead of 8 such as:
-
---------------------------------------------------------
-5H QH 3C AC 3H 4H QD 4C
-QC 9S 6H 9H 3S KS 3D 2C
-5D 2S JC 5C JH 6D AS 9C
-2D KD TH TC TD 8D 8C
-7H JS KH TS KC 7C QS
-AH 5S 6S AD 8H JD 4S
-7S 6C 7D 4D 8S 9D 2H
---------------------------------------------------------
-
 Non-pressing
 ------------
 

File fc-solve/source/lib.c

     int print_ts
     )
 {
-    char string[80], card_str[10];
+    char string[80];
 
     fcs_user_t * const user = (fcs_user_t *)api_instance;
 
     {
         return strdup("");
     }
-    fc_solve_card_perl2user(user->state_validity_card, card_str, print_ts);
 
     if (user->state_validity_ret == FCS_STATE_VALIDITY__EMPTY_SLOT)
     {
            (user->state_validity_ret == FCS_STATE_VALIDITY__MISSING_CARD)
           )
     {
+        /*
+         * user->state_validity_card is only valid for these states,
+         * so we should call fc_solve_card_perl2user on there only.
+         * */
+        char card_str[10];
+        fc_solve_card_perl2user(user->state_validity_card, card_str, print_ts);
+
         sprintf(string, "%s%s.",
             ((user->state_validity_ret == FCS_STATE_VALIDITY__EXTRA_CARD)? "There's an extra card: " : "There's a missing card: "),
             card_str

File fc-solve/source/t/t/data/sample-boards/24-with-7-cols.board

+5H QH 3C AC 3H 4H QD 4C
+QC 9S 6H 9H 3S KS 3D 2C
+5D 2S JC 5C JH 6D AS 9C
+2D KD TH TC TD 8D 8C
+7H JS KH TS KC 7C QS
+AH 5S 6S AD 8H JD 4S
+7S 6C 7D 4D 8S 9D 2H

File fc-solve/source/t/t/lib/FC_Solve/Test/Valgrind.pm

             "$ENV{FCS_PATH}/24.board",
         ],
         blurb => "Check the sanity of crashy-preset-1 which over-rides the soft-thread several times.",
-
+    },
+    {
+        id => "fc-solve-not-enough-input",
+        prog => "fc-solve",
+        argv => [
+            File::Spec->catfile(
+                $ENV{FCS_SRC_PATH},
+                qw(t t data sample-boards 24-with-7-cols.board),
+            ),
+        ],
+        blurb => "Check the sanity of not enough input.",
     },
     {
         id => "fc-solve-trim-max-stored-states",