]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CEntity.cpp
Fix reading one element past the end of an array.
[quix0rs-blobwars.git] / src / CEntity.cpp
index 988b6d19d38cbc113d5abdfe23db2ab2c9883e04..bf24711f515a90aca9ee442fa2bf34c9cce72281 100644 (file)
@@ -1,5 +1,6 @@
 /*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -22,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 Entity::Entity()
 {
-       strcpy(name, "");
+       name[0] = 0;
        x = y = dx = dy = tx = ty = width = height = 0;
        id = 0;
        health = 0;
@@ -52,7 +53,7 @@ Entity::Entity()
 
 void Entity::setName(const char *name)
 {
-       strcpy(this->name, name);
+       strlcpy(this->name, name, sizeof this->name);
 }
 
 void Entity::setSprites(Sprite *sprite1, Sprite *sprite2, Sprite *sprite3)