mirror of https://github.com/xiph/flac
examples: Fix error condition processing
Don't attempt to attach failed metadata objects. This also avoids clobbering the error flag if attaching the objects should succeed. There may still be problems later, for example calling _delete() on a possibly null metadata object pointer, but this it at least and improvement in the compromise between error handling and readability in C. Signed-off-by: Ralph Giles <giles@thaumas.net>
This commit is contained in:
parent
eba0ff8d3e
commit
a9557c13fa
|
@ -109,11 +109,13 @@ int main(int argc, char *argv[])
|
|||
) {
|
||||
fprintf(stderr, "ERROR: out of memory or tag error\n");
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
|
||||
metadata[1]->length = 1234; /* set the padding length */
|
||||
metadata[1]->length = 1234; /* set the padding length */
|
||||
|
||||
ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2);
|
||||
ok = FLAC__stream_encoder_set_metadata(encoder, metadata, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize encoder */
|
||||
|
|
|
@ -117,11 +117,13 @@ int main(int argc, char *argv[])
|
|||
) {
|
||||
fprintf(stderr, "ERROR: out of memory or tag error\n");
|
||||
ok = false;
|
||||
}
|
||||
} else {
|
||||
|
||||
metadata[1]->length = 1234; /* set the padding length */
|
||||
metadata[1]->length = 1234; /* set the padding length */
|
||||
|
||||
ok = encoder.set_metadata(metadata, 2);
|
||||
ok = encoder.set_metadata(metadata, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize encoder */
|
||||
|
|
Loading…
Reference in New Issue