Changeset 19024 in josm for trunk/src/org


Ignore:
Timestamp:
2024-04-02T18:57:56+02:00 (8 months ago)
Author:
taylor.smock
Message:

Fix #23550: Error when deserializing PBF Blog (patch by giora.kosoi, modified)

Modifications are as follows:

  • Added non-regression test
  • Removed unnecessary changes in Blob
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java

    r18877 r19024  
    185185        int size = Integer.MIN_VALUE;
    186186        Blob.CompressionType type = null;
    187         ProtobufRecord current = null;
     187        ProtobufRecord current;
     188        // Needed since size and compression type + compression data may be in a different order
     189        byte [] bytes = null;
    188190        while (parser.hasNext() && cis.getBytesRead() - start < header.dataSize()) {
    189191            current = new ProtobufRecord(baos, parser);
     
    191193                case 1:
    192194                    type = Blob.CompressionType.raw;
     195                    bytes = current.getBytes();
    193196                    break;
    194197                case 2:
     
    197200                case 3:
    198201                    type = Blob.CompressionType.zlib;
     202                    bytes = current.getBytes();
    199203                    break;
    200204                case 4:
    201205                    type = Blob.CompressionType.lzma;
     206                    bytes = current.getBytes();
    202207                    break;
    203208                case 5:
    204209                    type = Blob.CompressionType.bzip2;
     210                    bytes = current.getBytes();
    205211                    break;
    206212                case 6:
    207213                    type = Blob.CompressionType.lz4;
     214                    bytes = current.getBytes();
    208215                    break;
    209216                case 7:
    210217                    type = Blob.CompressionType.zstd;
     218                    bytes = current.getBytes();
    211219                    break;
    212220                default:
     
    217225            throw new IllegalStateException("Compression type not found, pbf may be malformed");
    218226        }
    219         return new Blob(size, type, current.getBytes());
     227        return new Blob(size, type, bytes);
    220228    }
    221229
Note: See TracChangeset for help on using the changeset viewer.