Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] (PR#6907) aidiplomat: Must check the result of pf_get_path
Home

[Freeciv-Dev] (PR#6907) aidiplomat: Must check the result of pf_get_path

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6907) aidiplomat: Must check the result of pf_get_path
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Wed, 19 Nov 2003 03:35:17 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6907 >


The function can return NULL.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "#!/usr/bin/perl -w
  if ( `date +%w` != 1 ) {
    die "This script only works on Mondays." ;
  }"
    -- from chkars.pl by Cornelius Krasel in de.comp.os.linux.misc

Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.29
diff -u -u -r1.29 aidiplomat.c
--- ai/aidiplomat.c     2003/11/19 11:29:59     1.29
+++ ai/aidiplomat.c     2003/11/19 11:32:01
@@ -513,6 +513,7 @@
 
       MAPSTEP(x, y, pos.x, pos.y, DIR_REVERSE(pos.dir_to_here));
       path = pf_get_path(map, pos.x, pos.y);
+      assert(path != NULL);
       if (!ai_unit_execute_path(punit, path) || punit->moves_left <= 0) {
         return FALSE;
       }
@@ -667,6 +668,7 @@
     struct pf_path *path;
 
     path = pf_get_path(map, goto_dest_x(punit), goto_dest_y(punit));
+    assert(path != NULL);
     if (ai_unit_execute_path(punit, path) && punit->moves_left > 0) {
       /* Check if we can do something with our destination now. */
       if (punit->ai.ai_role == AIUNIT_ATTACK) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6907) aidiplomat: Must check the result of pf_get_path, Raimar Falke <=