author | erik <erik> | 2007-02-08 01:45:16 (UTC) |
---|---|---|
committer | erik <erik> | 2007-02-08 01:45:16 (UTC) |
commit | 2e497f7cae45184184e2416114887095735958f5 (patch) (unidiff) | |
tree | a6b399d9bce5854dc7ad6c985b48965cf20680b0 /core/multimedia/opieplayer/vorbis/tremor/info.c | |
parent | 853b61f97e718359bef95147ab3c7beb0705acda (diff) | |
download | opie-2e497f7cae45184184e2416114887095735958f5.zip opie-2e497f7cae45184184e2416114887095735958f5.tar.gz opie-2e497f7cae45184184e2416114887095735958f5.tar.bz2 |
Each file in this commit has a problem where it is possible to dereference
a pointer without that pointer being valid. This commit fixes each instance
of that.
Diffstat (limited to 'core/multimedia/opieplayer/vorbis/tremor/info.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/vorbis/tremor/info.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/vorbis/tremor/info.c b/core/multimedia/opieplayer/vorbis/tremor/info.c index 941695e..3499ae4 100644 --- a/core/multimedia/opieplayer/vorbis/tremor/info.c +++ b/core/multimedia/opieplayer/vorbis/tremor/info.c | |||
@@ -52,98 +52,98 @@ static int tagcompare(const char *s1, const char *s2, int n){ | |||
52 | } | 52 | } |
53 | return 0; | 53 | return 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ | 56 | char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ |
57 | long i; | 57 | long i; |
58 | int found = 0; | 58 | int found = 0; |
59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 59 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
60 | char *fulltag = (char *)alloca(taglen+ 1); | 60 | char *fulltag = (char *)alloca(taglen+ 1); |
61 | 61 | ||
62 | strcpy(fulltag, tag); | 62 | strcpy(fulltag, tag); |
63 | strcat(fulltag, "="); | 63 | strcat(fulltag, "="); |
64 | 64 | ||
65 | for(i=0;i<vc->comments;i++){ | 65 | for(i=0;i<vc->comments;i++){ |
66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ | 66 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ |
67 | if(count == found) | 67 | if(count == found) |
68 | /* We return a pointer to the data, not a copy */ | 68 | /* We return a pointer to the data, not a copy */ |
69 | return vc->user_comments[i] + taglen; | 69 | return vc->user_comments[i] + taglen; |
70 | else | 70 | else |
71 | found++; | 71 | found++; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return NULL; /* didn't find anything */ | 74 | return NULL; /* didn't find anything */ |
75 | } | 75 | } |
76 | 76 | ||
77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ | 77 | int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ |
78 | int i,count=0; | 78 | int i,count=0; |
79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ | 79 | int taglen = strlen(tag)+1; /* +1 for the = we append */ |
80 | char *fulltag = (char *)alloca(taglen+1); | 80 | char *fulltag = (char *)alloca(taglen+1); |
81 | strcpy(fulltag,tag); | 81 | strcpy(fulltag,tag); |
82 | strcat(fulltag, "="); | 82 | strcat(fulltag, "="); |
83 | 83 | ||
84 | for(i=0;i<vc->comments;i++){ | 84 | for(i=0;i<vc->comments;i++){ |
85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) | 85 | if(!tagcompare(vc->user_comments[i], fulltag, taglen)) |
86 | count++; | 86 | count++; |
87 | } | 87 | } |
88 | 88 | ||
89 | return count; | 89 | return count; |
90 | } | 90 | } |
91 | 91 | ||
92 | void vorbis_comment_clear(vorbis_comment *vc){ | 92 | void vorbis_comment_clear(vorbis_comment *vc){ |
93 | if(vc){ | 93 | if(vc){ |
94 | long i; | 94 | long i; |
95 | for(i=0;i<vc->comments;i++) | 95 | for(i=0;i<vc->comments;i++) |
96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); | 96 | if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); |
97 | if(vc->user_comments)_ogg_free(vc->user_comments); | 97 | if(vc->user_comments)_ogg_free(vc->user_comments); |
98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); | 98 | if(vc->comment_lengths)_ogg_free(vc->comment_lengths); |
99 | if(vc->vendor)_ogg_free(vc->vendor); | 99 | if(vc->vendor)_ogg_free(vc->vendor); |
100 | memset(vc,0,sizeof(*vc)); | ||
100 | } | 101 | } |
101 | memset(vc,0,sizeof(*vc)); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. | 104 | /* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. |
105 | They may be equal, but short will never ge greater than long */ | 105 | They may be equal, but short will never ge greater than long */ |
106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ | 106 | int vorbis_info_blocksize(vorbis_info *vi,int zo){ |
107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; | 107 | codec_setup_info *ci = (codec_setup_info *)vi->codec_setup; |
108 | return ci ? ci->blocksizes[zo] : -1; | 108 | return ci ? ci->blocksizes[zo] : -1; |
109 | } | 109 | } |
110 | 110 | ||
111 | /* used by synthesis, which has a full, alloced vi */ | 111 | /* used by synthesis, which has a full, alloced vi */ |
112 | void vorbis_info_init(vorbis_info *vi){ | 112 | void vorbis_info_init(vorbis_info *vi){ |
113 | memset(vi,0,sizeof(*vi)); | 113 | memset(vi,0,sizeof(*vi)); |
114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); | 114 | vi->codec_setup=(codec_setup_info *)_ogg_calloc(1,sizeof(codec_setup_info)); |
115 | } | 115 | } |
116 | 116 | ||
117 | void vorbis_info_clear(vorbis_info *vi){ | 117 | void vorbis_info_clear(vorbis_info *vi){ |
118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | 118 | codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; |
119 | int i; | 119 | int i; |
120 | 120 | ||
121 | if(ci){ | 121 | if(ci){ |
122 | 122 | ||
123 | for(i=0;i<ci->modes;i++) | 123 | for(i=0;i<ci->modes;i++) |
124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); | 124 | if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); |
125 | 125 | ||
126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ | 126 | for(i=0;i<ci->maps;i++) /* unpack does the range checking */ |
127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); | 127 | _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); |
128 | 128 | ||
129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ | 129 | for(i=0;i<ci->floors;i++) /* unpack does the range checking */ |
130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); | 130 | _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); |
131 | 131 | ||
132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ | 132 | for(i=0;i<ci->residues;i++) /* unpack does the range checking */ |
133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); | 133 | _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); |
134 | 134 | ||
135 | for(i=0;i<ci->books;i++){ | 135 | for(i=0;i<ci->books;i++){ |
136 | if(ci->book_param[i]){ | 136 | if(ci->book_param[i]){ |
137 | /* knows if the book was not alloced */ | 137 | /* knows if the book was not alloced */ |
138 | vorbis_staticbook_destroy(ci->book_param[i]); | 138 | vorbis_staticbook_destroy(ci->book_param[i]); |
139 | } | 139 | } |
140 | if(ci->fullbooks) | 140 | if(ci->fullbooks) |
141 | vorbis_book_clear(ci->fullbooks+i); | 141 | vorbis_book_clear(ci->fullbooks+i); |
142 | } | 142 | } |
143 | if(ci->fullbooks) | 143 | if(ci->fullbooks) |
144 | _ogg_free(ci->fullbooks); | 144 | _ogg_free(ci->fullbooks); |
145 | 145 | ||
146 | _ogg_free(ci); | 146 | _ogg_free(ci); |
147 | } | 147 | } |
148 | 148 | ||
149 | memset(vi,0,sizeof(*vi)); | 149 | memset(vi,0,sizeof(*vi)); |