Permalink
Browse files

* Minor segfault protection.

  • Loading branch information...
1 parent 2c78e79 commit b669e4eba0f6ee3eedea24898fd908832c834489 @bobbens committed Aug 11, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/tech.c
View
@@ -810,6 +810,11 @@ Outfit** tech_getOutfit( tech_group_t *tech, int *n )
int m;
Outfit **o;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
/* Get the outfits. */
*n = 0;
m = 0;
@@ -842,6 +847,11 @@ Outfit** tech_getOutfitArray( tech_group_t **tech, int num, int *n )
tech_group_t grp;
Outfit **o;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
tech_createMetaGroup( &grp, tech, num );
o = tech_getOutfit( &grp, n );
tech_freeGroup( &grp );
@@ -864,6 +874,11 @@ Ship** tech_getShip( tech_group_t *tech, int *n )
int m;
Ship **s;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
/* Get the outfits. */
*n = 0;
m = 0;
@@ -896,6 +911,11 @@ Ship** tech_getShipArray( tech_group_t **tech, int num, int *n )
tech_group_t grp;
Ship **s;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
tech_createMetaGroup( &grp, tech, num );
s = tech_getShip( &grp, n );
tech_freeGroup( &grp );
@@ -919,6 +939,11 @@ Commodity** tech_getCommodityArray( tech_group_t **tech, int num, int *n )
tech_group_t grp;
Commodity **c;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
tech_createMetaGroup( &grp, tech, num );
c = tech_getCommodity( &grp, n );
tech_freeGroup( &grp );
@@ -941,6 +966,11 @@ Commodity** tech_getCommodity( tech_group_t *tech, int *n )
int m;
Commodity **c;
+ if (tech==NULL) {
+ *n = 0;
+ return NULL;
+ }
+
/* Get the commodities. */
*n = 0;
m = 0;

0 comments on commit b669e4e

Please sign in to comment.