Fix gcc warning tex may be used uninitialized in this function

This commit is contained in:
Pan7 2017-02-24 15:48:12 +01:00
parent 3bc866b623
commit bb3dd7421c
1 changed files with 43 additions and 0 deletions

View File

@ -246,6 +246,7 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
goto Fail; goto Fail;
} }
tex = NULL;
shdr = NULL; shdr = NULL;
/* process subchunks as they're encountered */ /* process subchunks as they're encountered */
@ -386,6 +387,9 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
case ID_TFLG: case ID_TFLG:
flags = getU2( fp ); flags = getU2( fp );
if( tex == NULL ) {
break;
}
//only one of the three axis bits should be set //only one of the three axis bits should be set
if ( flags & 1 ) { if ( flags & 1 ) {
tex->axis = 0; tex->axis = 0;
@ -421,21 +425,33 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TSIZ: case ID_TSIZ:
if( tex == NULL ) {
break;
}
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.size.val[ i ] = getF4( fp ); tex->tmap.size.val[ i ] = getF4( fp );
break; break;
case ID_TCTR: case ID_TCTR:
if( tex == NULL ) {
break;
}
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.center.val[ i ] = getF4( fp ); tex->tmap.center.val[ i ] = getF4( fp );
break; break;
case ID_TFAL: case ID_TFAL:
if( tex == NULL ) {
break;
}
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->tmap.falloff.val[ i ] = getF4( fp ); tex->tmap.falloff.val[ i ] = getF4( fp );
break; break;
case ID_TVEL: case ID_TVEL:
if( tex == NULL ) {
break;
}
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
v[ i ] = getF4( fp ); v[ i ] = getF4( fp );
tex->tmap.center.eindex = add_tvel( tex->tmap.center.val, v, tex->tmap.center.eindex = add_tvel( tex->tmap.center.val, v,
@ -443,6 +459,9 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TCLR: case ID_TCLR:
if( tex == NULL ) {
break;
}
if ( tex->type == ID_PROC ) { if ( tex->type == ID_PROC ) {
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )
tex->param.proc.value[ i ] = getU1( fp ) / 255.0f; tex->param.proc.value[ i ] = getU1( fp ) / 255.0f;
@ -450,40 +469,64 @@ lwSurface *lwGetSurface5( picoMemStream_t *fp, int cksize, lwObject *obj ){
break; break;
case ID_TVAL: case ID_TVAL:
if( tex == NULL ) {
break;
}
tex->param.proc.value[ 0 ] = getI2( fp ) / 256.0f; tex->param.proc.value[ 0 ] = getI2( fp ) / 256.0f;
break; break;
case ID_TAMP: case ID_TAMP:
if( tex == NULL ) {
break;
}
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.amplitude.val = getF4( fp ); tex->param.imap.amplitude.val = getF4( fp );
} }
break; break;
case ID_TIMG: case ID_TIMG:
if( tex == NULL ) {
break;
}
s = getS0( fp ); s = getS0( fp );
tex->param.imap.cindex = add_clip( s, &obj->clip, &obj->nclips ); tex->param.imap.cindex = add_clip( s, &obj->clip, &obj->nclips );
break; break;
case ID_TAAS: case ID_TAAS:
if( tex == NULL ) {
break;
}
tex->param.imap.aa_strength = getF4( fp ); tex->param.imap.aa_strength = getF4( fp );
tex->param.imap.aas_flags = 1; tex->param.imap.aas_flags = 1;
break; break;
case ID_TREF: case ID_TREF:
if( tex == NULL ) {
break;
}
tex->tmap.ref_object = getbytes( fp, sz ); tex->tmap.ref_object = getbytes( fp, sz );
break; break;
case ID_TOPC: case ID_TOPC:
if( tex == NULL ) {
break;
}
tex->opacity.val = getF4( fp ); tex->opacity.val = getF4( fp );
break; break;
case ID_TFP0: case ID_TFP0:
if( tex == NULL ) {
break;
}
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.wrapw.val = getF4( fp ); tex->param.imap.wrapw.val = getF4( fp );
} }
break; break;
case ID_TFP1: case ID_TFP1:
if( tex == NULL ) {
break;
}
if ( tex->type == ID_IMAP ) { if ( tex->type == ID_IMAP ) {
tex->param.imap.wraph.val = getF4( fp ); tex->param.imap.wraph.val = getF4( fp );
} }