Skip to content

Commit

Permalink
x265 plugin: make sure that memory for returned error message exists (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 17, 2024
1 parent 662891e commit 61ac80b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions libheif/plugins/encoder_x265.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ enum parameter_type

struct parameter
{


parameter_type type = UndefinedType;
std::string name;

Expand Down Expand Up @@ -85,6 +83,8 @@ struct encoder_struct_x265
std::string tune;

int logLevel = X265_LOG_NONE;

std::string last_error_message;
};


Expand Down Expand Up @@ -860,15 +860,13 @@ static struct heif_error x265_encode_image(void* encoder_raw, const struct heif_
else if (strncmp(p.name.c_str(), "x265:", 5) == 0) {
std::string x265p = p.name.substr(5);
if (api->param_parse(param, x265p.c_str(), p.value_string.c_str()) < 0) {
char error_message[1024];
strcpy(error_message, "Unsupported internal encoder parameter: ");
strcat(error_message, p.name.c_str());
struct heif_error err = {
encoder->last_error_message = std::string{"Unsupported x265 encoder parameter: "} + x265p;

return {
.code = heif_error_Usage_error,
.subcode = heif_suberror_Unsupported_parameter,
.message = error_message
.message = encoder->last_error_message.c_str()
};
return err;
}
}
}
Expand Down

0 comments on commit 61ac80b

Please sign in to comment.