Changeset aa5633ce030a91165f913c1583234dd73d34f549
- Timestamp:
- 14/08/08 22:37:21
(4 months ago)
- Author:
- Rémi Duraffort <ivoire@videolan.org>
- git-committer:
- Rémi Duraffort <ivoire@videolan.org> 1218746241 +0200
- git-parent:
[ec9ad1e9893a58ffb3edd80a5a31c094cd6e813e]
- git-author:
- Rémi Duraffort <ivoire@videolan.org> 1218746241 +0200
- Message:
Use asprintf instead of malloc+sprintf (and check the return value)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r943b5cc |
raa5633c |
|
| 444 | 444 | msg_Dbg( p_access, "track[%d] start=%d", i, p_sys->p_sectors[i] ); |
|---|
| 445 | 445 | char *psz_uri, *psz_opt, *psz_first, *psz_last; |
|---|
| 446 | | int i_path_len = p_access->psz_path ? strlen( p_access->psz_path ) : 0; |
|---|
| 447 | | |
|---|
| 448 | | psz_name = (char*)malloc( strlen( _("Audio CD - Track ") ) + 5 ); |
|---|
| 449 | | psz_opt = (char*)malloc( strlen( "cdda-track=" ) + 3 ); |
|---|
| 450 | | psz_first = (char*)malloc( strlen( "cdda-first-sector=" ) + 7 ); |
|---|
| 451 | | psz_last = (char*)malloc( strlen( "cdda-last-sector=" ) + 7 ); |
|---|
| 452 | | psz_uri = (char*)malloc( i_path_len + 13 ); |
|---|
| 453 | | |
|---|
| 454 | | snprintf( psz_uri, i_path_len + 13, "cdda://%s", |
|---|
| 455 | | p_access->psz_path ? p_access->psz_path : "" ); |
|---|
| 456 | | sprintf( psz_opt, "cdda-track=%i", i+1 ); |
|---|
| 457 | | sprintf( psz_first, "cdda-first-sector=%i",p_sys->p_sectors[i] ); |
|---|
| | 446 | |
|---|
| | 447 | if( asprintf( &psz_uri, "cdda://%s", p_access->psz_path ? p_access->psz_path : "" ) == -1 ) |
|---|
| | 448 | psz_uri = NULL; |
|---|
| | 449 | if( asprintf( &psz_opt, "cdda-track=%i", i+1 ) == -1 ) |
|---|
| | 450 | psz_opt = NULL; |
|---|
| | 451 | if( asprintf( &psz_first, "cdda-first-sector=%i",p_sys->p_sectors[i] ) == -1 ) |
|---|
| | 452 | psz_first = NULL; |
|---|
| 458 | 453 | |
|---|
| 459 | 454 | // if( i != i_titles -1 ) |
|---|
| 460 | | sprintf( psz_last, "cdda-last-sector=%i", p_sys->p_sectors[i+1] ); |
|---|
| 461 | | // else |
|---|
| 462 | | // sprintf( psz_last, "cdda-last-sector=%i", 1242 /* FIXME */); |
|---|
| | 455 | // { |
|---|
| | 456 | if( asprintf( &psz_last, "cdda-last-sector=%i", p_sys->p_sectors[i+1] ) == -1 ) |
|---|
| | 457 | psz_last = NULL; |
|---|
| | 458 | // } |
|---|
| | 459 | // else |
|---|
| | 460 | // { |
|---|
| | 461 | // if( asprintf( &psz_last, "cdda-last-sector=%i", 1242 /* FIXME */) == -1 ) |
|---|
| | 462 | // psz_last = NULL; |
|---|
| | 463 | // } |
|---|
| 463 | 464 | |
|---|
| 464 | 465 | /* Define a "default name" */ |
|---|
| 465 | | sprintf( psz_name, _("Audio CD - Track %i"), (i+1) ); |
|---|
| | 466 | if( asprintf( &psz_name, _("Audio CD - Track %i"), (i+1) ) == -1 ) |
|---|
| | 467 | psz_name = NULL; |
|---|
| 466 | 468 | |
|---|
| 467 | 469 | /* Create playlist items */ |
|---|