mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-01 07:04:30 +02:00
fix(YouTube - Spoof Streaming Data): Fix memory leak in ByteArrayOutputStream
(#102)
This commit is contained in:
parent
b31865afbe
commit
cbac88b2b5
@ -169,26 +169,26 @@ public class StreamingDataRequest {
|
||||
);
|
||||
|
||||
private static ByteBuffer fetch(@NonNull String videoId, Map<String, String> playerHeaders) {
|
||||
try {
|
||||
lastSpoofedClientType = null;
|
||||
lastSpoofedClientType = null;
|
||||
|
||||
// Retry with different client if empty response body is received.
|
||||
for (ClientType clientType : CLIENT_ORDER_TO_USE) {
|
||||
HttpURLConnection connection = send(clientType, videoId, playerHeaders);
|
||||
// Retry with different client if empty response body is received.
|
||||
for (ClientType clientType : CLIENT_ORDER_TO_USE) {
|
||||
HttpURLConnection connection = send(clientType, videoId, playerHeaders);
|
||||
|
||||
// gzip encoding doesn't response with content length (-1),
|
||||
// but empty response body does.
|
||||
if (connection == null || connection.getContentLength() == 0) {
|
||||
continue;
|
||||
}
|
||||
// gzip encoding doesn't response with content length (-1),
|
||||
// but empty response body does.
|
||||
if (connection == null || connection.getContentLength() == 0)
|
||||
continue;
|
||||
|
||||
try (
|
||||
InputStream inputStream = new BufferedInputStream(connection.getInputStream());
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream()
|
||||
) {
|
||||
byte[] buffer = new byte[2048];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) >= 0) {
|
||||
baos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
inputStream.close();
|
||||
if (clientType == ClientType.IOS && liveStreams.check(buffer).isFiltered()) {
|
||||
Logger.printDebug(() -> "Ignore IOS spoofing as it is a livestream (video: " + videoId + ")");
|
||||
continue;
|
||||
@ -196,9 +196,9 @@ public class StreamingDataRequest {
|
||||
lastSpoofedClientType = clientType;
|
||||
|
||||
return ByteBuffer.wrap(baos.toByteArray());
|
||||
} catch (IOException ex) {
|
||||
Logger.printException(() -> "Fetch failed while processing response data", ex);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.printException(() -> "Fetch failed while processing response data", ex);
|
||||
}
|
||||
|
||||
handleConnectionError("Could not fetch any client streams", null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user