Skip to content

Commit b1d6158

Browse files
committed
Fix memory leak
1 parent 230b7ec commit b1d6158

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Modules/_testexternalinspection.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,25 +577,28 @@ read_py_long(
577577
}
578578
bytes_read = read_memory(pid, address + offsets->long_object.ob_digit, sizeof(digit) * size, digits);
579579
if (bytes_read < 0) {
580-
return -1;
580+
goto error;
581581
}
582582

583583
long value = 0;
584584

585585
for (ssize_t i = 0; i < size; ++i) {
586586
long long factor;
587587
if (__builtin_mul_overflow(digits[i], (1Lu << (ssize_t)(shift * i)), &factor)) {
588-
return -1;
588+
goto error;
589589
}
590590
if (__builtin_add_overflow(value, factor, &value)) {
591-
return -1;
591+
goto error;
592592
}
593593
}
594+
PyMem_RawFree(digits);
594595
if (negative) {
595596
value = -1 * value;
596597
}
597-
598598
return value;
599+
error:
600+
PyMem_RawFree(digits);
601+
return -1;
599602
}
600603

601604
static PyObject *

0 commit comments

Comments
 (0)