Changeset 1684a6ae8733789c2ea9d41e0c45fd75832aea3d
- Timestamp:
- 23/03/07 19:48:04
(2 years ago)
- Author:
- Laurent Aimar <fenrir@videolan.org>
- git-committer:
- Laurent Aimar <fenrir@videolan.org> 1174675684 +0000
- git-parent:
[042f53c95bf6d6c58573d1a56bde0785002ff2c2]
- git-author:
- Laurent Aimar <fenrir@videolan.org> 1174675684 +0000
- Message:
Fixed dvbsi_to_utf8 (memory leak + possible segfault)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r6185bee |
r1684a6a |
|
| 2310 | 2310 | } |
|---|
| 2311 | 2311 | |
|---|
| | 2312 | static inline void *FixUTF8( char *p ) |
|---|
| | 2313 | { |
|---|
| | 2314 | EnsureUTF8( p ); |
|---|
| | 2315 | return p; |
|---|
| | 2316 | } |
|---|
| | 2317 | |
|---|
| 2312 | 2318 | static char *dvbsi_to_utf8( char *psz_instring, size_t i_length ) |
|---|
| 2313 | 2319 | { |
|---|
| … | … | |
| 2318 | 2324 | vlc_iconv_t iconv_handle; |
|---|
| 2319 | 2325 | if( i_length < 1 ) return NULL; |
|---|
| 2320 | | if( psz_instring[0] >= 0x20 ) |
|---|
| | 2326 | if( psz_instring[0] < 0 || psz_instring[0] >= 0x20 ) |
|---|
| 2321 | 2327 | { |
|---|
| 2322 | 2328 | psz_stringstart = psz_instring; |
|---|
| … | … | |
| 2371 | 2377 | if( i_length < 3 || psz_instring[1] != '\0' || psz_instring[2] > 0x0f |
|---|
| 2372 | 2378 | || psz_instring[2] == 0 ) |
|---|
| 2373 | | return EnsureUTF8(strndup(psz_instring,i_length)); |
|---|
| | 2379 | return FixUTF8(strndup(psz_instring,i_length)); |
|---|
| 2374 | 2380 | sprintf( psz_encbuf, "ISO_8859-%d", psz_instring[2] ); |
|---|
| 2375 | 2381 | psz_stringstart = &psz_instring[3]; |
|---|
| … | … | |
| 2393 | 2399 | break; |
|---|
| 2394 | 2400 | case 0x15: |
|---|
| 2395 | | return EnsureUTF8(strndup(&psz_instring[1],i_length-1)); |
|---|
| | 2401 | return FixUTF8(strndup(&psz_instring[1],i_length-1)); |
|---|
| 2396 | 2402 | break; |
|---|
| 2397 | 2403 | default: |
|---|
| 2398 | 2404 | /* invalid */ |
|---|
| 2399 | | return EnsureUTF8(strndup(psz_instring,i_length)); |
|---|
| | 2405 | return FixUTF8(strndup(psz_instring,i_length)); |
|---|
| 2400 | 2406 | } |
|---|
| 2401 | 2407 | iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding ); |
|---|