mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Initialize context memory after allocation to prevent undefined behavior
This commit is contained in:
@@ -150,7 +150,6 @@ void *aaruf_open(const char *filepath) // NOLINT(readability-function-size)
|
|||||||
|
|
||||||
TRACE("Allocating memory for context");
|
TRACE("Allocating memory for context");
|
||||||
ctx = (aaruformatContext *)malloc(sizeof(aaruformatContext));
|
ctx = (aaruformatContext *)malloc(sizeof(aaruformatContext));
|
||||||
memset(ctx, 0, sizeof(aaruformatContext));
|
|
||||||
|
|
||||||
if(ctx == NULL)
|
if(ctx == NULL)
|
||||||
{
|
{
|
||||||
@@ -161,6 +160,8 @@ void *aaruf_open(const char *filepath) // NOLINT(readability-function-size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memset(ctx, 0, sizeof(aaruformatContext));
|
||||||
|
|
||||||
TRACE("Opening file %s", filepath);
|
TRACE("Opening file %s", filepath);
|
||||||
ctx->imageStream = fopen(filepath, "rb");
|
ctx->imageStream = fopen(filepath, "rb");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user