Changeset 1226


Ignore:
Timestamp:
14/04/09 16:16:26 (3 years ago)
Author:
Freddie Akeroyd
Message:

Fix possible NXdataset issue by adding 1 to allocated size to cover
string NULL termination. Refs #174.

Location:
branches/4.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2/applications/nxconvert_common.c

    r1225 r1226  
    187187                if (NXmalloc (&dataBuffer, dataRank, dataDimensions, dataType) != NX_OK) return NX_ERROR; 
    188188                if (NXgetdata (inId, dataBuffer)  != NX_OK) return NX_ERROR; 
    189                 if (dataType == NX_CHAR) { 
    190                    dataDimensions[0] = strlen((char*)dataBuffer)+1; 
    191                 } 
    192189                if (NXmakedata (outId, name, dataType, dataRank, dataDimensions) != NX_OK) return NX_ERROR; 
    193190                if (NXopendata (outId, name) != NX_OK) return NX_ERROR; 
  • branches/4.2/src/nxdataset.c

    r952 r1226  
    4747    length *= dim[i]; 
    4848  } 
    49   pNew->u.ptr = malloc(length*getTypeSize(typecode)); 
     49  /* add +1 in case of string NULL termination */ 
     50  pNew->u.ptr = malloc(length*getTypeSize(typecode)+1); 
    5051 
    5152  if(pNew->dim == NULL || pNew->u.ptr == NULL){ 
     
    6061  } 
    6162  pNew->magic = MAGIC; 
    62   memset(pNew->u.ptr,0,length*getTypeSize(typecode)); 
     63  /* add +1 in case of string NULL termination  - see above */ 
     64  memset(pNew->u.ptr,0,length*getTypeSize(typecode)+1); 
    6365  return pNew; 
    6466} 
Note: See TracChangeset for help on using the changeset viewer.