[FFmpeg-devel] [PATCH] libavcodec/nvenc.c: memset NV_ENC_REGISTER_RESOURCE structure with zeros

Timo Rothenpieler timo at rothenpieler.org
Mon Jan 10 16:55:06 EET 2022


On 10.01.2022 13:49, Roman Arzumanyan wrote:
> Hello,
> 
> This patch memsets NV_ENC_REGISTER_RESOURCE structure with zeros.
> Without that, in rare occasions NV_ENC_REGISTER_RESOURCE::bufferUsage 
> structure field may accidentaly take NV_ENC_OUTPUT_MOTION_VECTOR value 
> causing nvEncRegisterResource() function to fail.

The rest of nvenc.c uses "= { 0 };" to zero-initialize structs.
For some reason this wasn't done here.
This would be the only instance of using memset() in the whole file.

Do you have a way to check if just doing

NV_ENC_REGISTER_RESOURCE reg = { 0 };

Also solves the issue?

I just pushed that change, since it's clearly an oversight.
If it's still causing issues, let me know and memset is definitely an 
option.
But any standard-abiding C-Compiler should zero initialize the struct now.



Thanks,
Timo


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4494 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220110/be9b247e/attachment.bin>


More information about the ffmpeg-devel mailing list