From 5d4de366d7092aefc26246ab1a4039f8bd30d7fa Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Fri, 29 Mar 2024 16:45:59 +0000 Subject: [PATCH] 8286705: GCC 12 reports use-after-free potential bugs Reviewed-by: phh Backport-of: 0e4bece5b5143b8505496ea7430bbfa11e151aff --- src/java.base/share/native/libjli/parse_manifest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/native/libjli/parse_manifest.c b/src/java.base/share/native/libjli/parse_manifest.c index 2889fab0686..a0d87b8bb9e 100644 --- a/src/java.base/share/native/libjli/parse_manifest.c +++ b/src/java.base/share/native/libjli/parse_manifest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -288,8 +288,8 @@ find_positions(int fd, Byte *eb, jlong* base_offset, jlong* censtart) for (cp = &buffer[bytes - ENDHDR]; cp >= &buffer[0]; cp--) if (ENDSIG_AT(cp) && (cp + ENDHDR + ENDCOM(cp) == endpos)) { (void) memcpy(eb, cp, ENDHDR); - free(buffer); pos = flen - (endpos - cp); + free(buffer); return find_positions64(fd, eb, pos, base_offset, censtart); } free(buffer);