Skip to content

Commit 9a6de4e

Browse files
committed
Merge pull request #11393 from kawochen/BUG-FIX-11344
BUG: GH11344 in pandas.json when file to read is big
2 parents 1b2e45a + fe6c72e commit 9a6de4e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

doc/source/whatsnew/v0.17.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Bug Fixes
111111
- Bug in ``DataFrame.to_latex()`` produces an extra rule when ``header=False`` (:issue:`7124`)
112112

113113

114-
114+
- Bug in ``pandas.json`` when file to load is big (:issue:`11344`)
115115
- Bugs in ``to_excel`` with duplicate columns (:issue:`11007`, :issue:`10982`, :issue:`10970`)
116116
- Fixed a bug that prevented the construction of an empty series of dtype
117117
``datetime64[ns, tz]`` (:issue:`11245`).

pandas/src/ujson/lib/ultrajsondec.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
443443

444444
if (ds->escHeap)
445445
{
446-
if (newSize > (UINT_MAX / sizeof(wchar_t)))
446+
if (newSize > (SIZE_MAX / sizeof(wchar_t)))
447447
{
448448
return SetError(ds, -1, "Could not reserve memory block");
449449
}
@@ -458,8 +458,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
458458
else
459459
{
460460
wchar_t *oldStart = ds->escStart;
461-
ds->escHeap = 1;
462-
if (newSize > (UINT_MAX / sizeof(wchar_t)))
461+
if (newSize > (SIZE_MAX / sizeof(wchar_t)))
463462
{
464463
return SetError(ds, -1, "Could not reserve memory block");
465464
}
@@ -468,6 +467,7 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_string ( struct DecoderState *ds)
468467
{
469468
return SetError(ds, -1, "Could not reserve memory block");
470469
}
470+
ds->escHeap = 1;
471471
memcpy(ds->escStart, oldStart, escLen * sizeof(wchar_t));
472472
}
473473

0 commit comments

Comments
 (0)