Skip to content

Commit

Permalink
Provisional fix for agronholm#169
Browse files Browse the repository at this point in the history
Fixes compiler warnings for unsigned int format string types.
  • Loading branch information
Sekenre committed Jun 14, 2023
1 parent 66c2d22 commit 8ff87a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <math.h>
#include <structmember.h>
#include <datetime.h>
#include <inttypes.h>
#include "module.h"
#include "halffloat.h"
#include "tags.h"
Expand Down Expand Up @@ -602,7 +603,7 @@ decode_bytestring(CBORDecoderObject *self, uint8_t subtype)
return NULL;

if (length > (uint64_t)PY_SSIZE_T_MAX - (uint64_t)PyBytesObject_SIZE) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive bytestring size 0x%s", length_hex);
Expand Down Expand Up @@ -703,7 +704,7 @@ decode_string(CBORDecoderObject *self, uint8_t subtype)
if (decode_length(self, subtype, &length, &indefinite) == -1)
return NULL;
if (length > (uint64_t)PY_SSIZE_T_MAX - (uint64_t)PyBytesObject_SIZE) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive string size 0x%s", length_hex);
Expand Down Expand Up @@ -860,7 +861,7 @@ decode_array(CBORDecoderObject *self, uint8_t subtype)
if (indefinite)
return decode_indefinite_array(self);
if (length > (uint64_t)PY_SSIZE_T_MAX) {
sprintf(length_hex, "%llX", length);
sprintf(length_hex, "%" PRIX64, length);
PyErr_Format(
_CBOR2_CBORDecodeValueError,
"excessive array size 0x%s", length_hex);
Expand Down

0 comments on commit 8ff87a8

Please sign in to comment.