Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions nifti2/nifti2_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8805,8 +8805,10 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )
/* scan for opening string */

spos = 0 ;
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ; spos += nn ;
if( ii == 0 || strcmp(lhs,"<nifti_image") != 0 ) return NULL ;
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ;
if( ii != 1 ) return NULL ; /* nothing scanned: lhs and nn are unset */
spos += nn ;
if( strcmp(lhs,"<nifti_image") != 0 ) return NULL ;

/* create empty image struct */

Expand Down Expand Up @@ -8835,8 +8837,10 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )

/* get lhs string */

ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ; spos += nn ;
if( ii == 0 || strcmp(lhs,"/>") == 0 ) break ; /* end of input? */
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ;
if( ii != 1 ) break ; /* nothing scanned: lhs and nn are unset */
spos += nn ;
if( strcmp(lhs,"/>") == 0 ) break ; /* end of input? */

/* skip whitespace and the '=' marker */

Expand All @@ -8853,8 +8857,9 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )
memcpy(rhs,str+spos+1,nn) ; rhs[nn] = '\0' ;
spos = (str[ii] == '\'') ? ii+1 : ii ;
} else {
ii = sscanf( str+spos , "%1023s%n" , rhs , &nn ) ; spos += nn ;
if( ii == 0 ) break ; /* nothing found? */
ii = sscanf( str+spos , "%1023s%n" , rhs , &nn ) ;
if( ii != 1 ) break ; /* nothing found: rhs and nn are unset */
spos += nn ;
}
unescape_string(rhs) ; /* remove any XML escape sequences */

Expand Down
17 changes: 11 additions & 6 deletions niftilib/nifti1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -6663,8 +6663,10 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )
/* scan for opening string */

spos = 0 ;
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ; spos += nn ;
if( ii == 0 || strcmp(lhs,"<nifti_image") != 0 ) return NULL ;
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ;
if( ii != 1 ) return NULL ; /* nothing scanned: lhs and nn are unset */
spos += nn ;
if( strcmp(lhs,"<nifti_image") != 0 ) return NULL ;

/* create empty image struct */

Expand Down Expand Up @@ -6693,8 +6695,10 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )

/* get lhs string */

ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ; spos += nn ;
if( ii == 0 || strcmp(lhs,"/>") == 0 ) break ; /* end of input? */
ii = sscanf( str+spos , "%1023s%n" , lhs , &nn ) ;
if( ii != 1 ) break ; /* nothing scanned: lhs and nn are unset */
spos += nn ;
if( strcmp(lhs,"/>") == 0 ) break ; /* end of input? */

/* skip whitespace and the '=' marker */

Expand All @@ -6711,8 +6715,9 @@ nifti_image *nifti_image_from_ascii( const char *str, int * bytes_read )
memcpy(rhs,str+spos+1,nn) ; rhs[nn] = '\0' ;
spos = (str[ii] == '\'') ? ii+1 : ii ;
} else {
ii = sscanf( str+spos , "%1023s%n" , rhs , &nn ) ; spos += nn ;
if( ii == 0 ) break ; /* nothing found? */
ii = sscanf( str+spos , "%1023s%n" , rhs , &nn ) ;
if( ii != 1 ) break ; /* nothing found: rhs and nn are unset */
spos += nn ;
}
unescape_string(rhs) ; /* remove any XML escape sequences */

Expand Down
Loading