Skip to content

Fix: Mark JSON encoding flag constants as unsigned to avoid signed overflow issues - #754

Open
maruixin-kls wants to merge 1 commit into
akheron:masterfrom
maruixin-kls:fix/issue-694-unsigned-flags
Open

maruixin-kls wants to merge 1 commit into
akheron:masterfrom
maruixin-kls:fix/issue-694-unsigned-flags

Conversation

@maruixin-kls

Copy link
Copy Markdown

This PR addresses issue #694.

Problem:

The JSON encoding flag constants (e.g., JSON_COMPACT, JSON_SORT_KEYS) were defined as signed integers by default. When these flags are combined or used in bitwise operations, it can lead to undefined behavior or compiler warnings regarding signed overflow, especially on platforms where int is 32-bit.

Solution:

Added the u suffix to all hexadecimal flag constants in src/jansson.h to explicitly define them as unsigned int.

Changes:

Modified JSON_MAX_INDENT, JSON_COMPACT, JSON_ENSURE_ASCII, etc., to use the u suffix.
Closes #694.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The #define for JSON flags should be unsigned constants.

1 participant