Does not write an empty section

This commit is contained in:
Volker Berlin 2017-03-24 22:14:33 +01:00
parent 940195cdf0
commit 984cfb2bc5

View File

@ -116,8 +116,12 @@ class WasmOutputStream extends FilterOutputStream {
*/
void writeSection( SectionType type, WasmOutputStream data, String name ) throws IOException {
ByteArrayOutputStream baos = (ByteArrayOutputStream)data.out;
int size = baos.size();
if( size == 0 ) {
return;
}
writeVaruint32( type.ordinal() );
writeVaruint32( baos.size() );
writeVaruint32( size );
if( type == SectionType.Custom ) {
byte[] bytes = name.getBytes( StandardCharsets.ISO_8859_1 );
writeVaruint32( bytes.length );