godotengine / godotengine/godot-docs

Binary serialization for PoolStringArray uses null-terminated byte strings

Open
#4,087 0 comments 0 reactions 0 assignees View on GitHub
area:manual bug
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Godot version:**
3.2.2-stable (commit 6a9fbafcbbd7954761fb17554ed08fb62e3554dd)

**OS/device including version:**
ArchLinux (Linux 5.7.4) x86_64, I don't think GPU is related here

**Issue description:**
PoolStringArray serialization is not as documented (https://docs.godotengine.org/en/stable/tutorials/misc/binary_serialization_api.html). String lengths are up by 1 (Null-terminated byte strings) while serializing a string doesn't have this behavior.

**Steps to reproduce:**
A simple code like :
```
prints(len('test'), var2bytes('test').hex_encode())
prints(len(PoolStringArray(['test'])[0]), var2bytes(PoolStringArray(['test'])).hex_encode())
```

will produce :
```
4 040000000400000074657374
4 1700000001000000050000007465737400000000
```
For readability we can see the final has as : 1700 0000 0100 0000 0500 0000 7465 7374 0000 0000

* 1700 0000 => 23 : PoolStringArray
* 0100 0000 => 1 : length of the PoolStringArray
* 0500 0000 => 5 : length of the string ('test')
* 7465 7374 0000 0000 => string (7465 7374 00 + 4 byte padding)

**Minimal reproduction project:**
[poolstringarray_serialization.zip](https://github.com/godotengine/godot/files/4841812/poolstringarray_serialization.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.