Found by Coverity; also see commit 85fb2af3.
Unified · Split
| @@ -78,8 +78,7 @@ static int control(struct af_instance* af, int cmd, void* arg) · 77 unmodified lines | ||
| 78 | 78 | int mapsize; |
| 79 | 79 | |
| 80 | 80 | // Free previous buffers |
| 81 | − if (s->buf) | |
| 82 | − free(s->buf[0]); | |
| 81 | + free(s->buf[0]); | |
| 83 | 82 | |
| 84 | 83 | // unmap previous area |
| 85 | 84 | if(s->mmap_area) |
| @@ -94,8 +93,10 @@ static int control(struct af_instance* af, int cmd, void* arg) · 8 unmodified lines | ||
| 94 | 93 | |
| 95 | 94 | // Allocate new buffers (as one continuous block) |
| 96 | 95 | s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps); |
| 97 | − if(NULL == s->buf[0]) | |
| 96 | + if(NULL == s->buf[0]) { | |
| 98 | 97 | MP_FATAL(af, "Out of memory\n"); |
| 98 | + return AF_ERROR; | |
| 99 | + } | |
| 99 | 100 | for(i = 1; i < af->data->nch; i++) |
| 100 | 101 | s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps; |
| 101 | 102 | |
| @@ -147,8 +148,8 @@ static int control(struct af_instance* af, int cmd, void* arg) · 45 unmodified lines | ||
| 147 | 148 | static void uninit( struct af_instance* af ) |
| 148 | 149 | { |
| 149 | 150 | af_export_t* s = af->priv; |
| 150 | − if (s->buf) | |
| 151 | − free(s->buf[0]); | |
| 151 | + | |
| 152 | + free(s->buf[0]); | |
| 152 | 153 | |
| 153 | 154 | // Free mmaped area |
| 154 | 155 | if(s->mmap_area) |
| @@ -305,7 +305,7 @@ int mp_input_get_keys_from_string(char *name, int max_num_keys, · 304 unmodified lines | ||
| 305 | 305 | |
| 306 | 306 | ptr = name; |
| 307 | 307 | n = 0; |
| 308 | − for (end = strchr(ptr, '-'); ptr != NULL; end = strchr(ptr, '-')) { | |
| 308 | + for (end = strchr(ptr, '-'); ; end = strchr(ptr, '-')) { | |
| 309 | 309 | if (end && end[1] != '\0') { |
| 310 | 310 | if (end[1] == '-') |
| 311 | 311 | end = &end[1]; |
| @@ -2288,23 +2288,20 @@ bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l, · 2287 unmodified lines | ||
| 2288 | 2288 | if (bstr_equals0(name, dst->name)) |
| 2289 | 2289 | return true; |
| 2290 | 2290 | } |
| 2291 | − if (l->aliases) { | |
| 2292 | − for (int i = 0; l->aliases[i][0]; i++) { | |
| 2293 | − const char *aname = l->aliases[i][0]; | |
| 2294 | − const char *alias = l->aliases[i][1]; | |
| 2295 | − const char *opts = l->aliases[i][2]; | |
| 2296 | − if (bstr_equals0(name, aname) && | |
| 2297 | − m_obj_list_find(dst, l, bstr0(alias))) | |
| 2298 | − { | |
| 2299 | − if (opts) { | |
| 2300 | − dst->init_options = opts; | |
| 2301 | − } else { | |
| 2302 | − // Assume it's deprecated in this case. | |
| 2303 | − // Also, it's used by the VO code only, so whatever. | |
| 2304 | − dst->replaced_name = aname; | |
| 2305 | − } | |
| 2306 | − return true; | |
| 2291 | + for (int i = 0; l->aliases[i][0]; i++) { | |
| 2292 | + const char *aname = l->aliases[i][0]; | |
| 2293 | + const char *alias = l->aliases[i][1]; | |
| 2294 | + const char *opts = l->aliases[i][2]; | |
| 2295 | + if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias))) | |
| 2296 | + { | |
| 2297 | + if (opts) { | |
| 2298 | + dst->init_options = opts; | |
| 2299 | + } else { | |
| 2300 | + // Assume it's deprecated in this case. | |
| 2301 | + // Also, it's used by the VO code only, so whatever. | |
| 2302 | + dst->replaced_name = aname; | |
| 2307 | 2303 | } |
| 2304 | + return true; | |
| 2308 | 2305 | } |
| 2309 | 2306 | } |
| 2310 | 2307 | return false; |
| @@ -438,13 +438,12 @@ ssize_t RarRead(rar_file_t *file, void *data, size_t size) · 437 unmodified lines | ||
| 438 | 438 | if (max <= 0) |
| 439 | 439 | break; |
| 440 | 440 | |
| 441 | − int r = file->s ? stream_read(file->s, data, max) : -1; | |
| 441 | + int r = stream_read(file->s, data, max); | |
| 442 | 442 | if (r <= 0) |
| 443 | 443 | break; |
| 444 | 444 | |
| 445 | 445 | total += r; |
| 446 | − if( data ) | |
| 447 | − data = (char *)data + r; | |
| 446 | + data = (char *)data + r; | |
| 448 | 447 | file->i_pos += r; |
| 449 | 448 | if (file->i_pos >= chunk_end && |
| 450 | 449 | RarSeek(file, file->i_pos)) |