Initialize context memory after allocation to prevent undefined behavior

This commit is contained in:
2025-10-08 19:37:36 +01:00
parent 1e9ca18c6f
commit 95f9aa6f65

View File

@@ -150,7 +150,6 @@ void *aaruf_open(const char *filepath) // NOLINT(readability-function-size)
TRACE("Allocating memory for context");
ctx = (aaruformatContext *)malloc(sizeof(aaruformatContext));
memset(ctx, 0, sizeof(aaruformatContext));
if(ctx == NULL)
{
@@ -161,6 +160,8 @@ void *aaruf_open(const char *filepath) // NOLINT(readability-function-size)
return NULL;
}
memset(ctx, 0, sizeof(aaruformatContext));
TRACE("Opening file %s", filepath);
ctx->imageStream = fopen(filepath, "rb");