OpenPrinting / libcups

OpenPrinting CUPS Library Sources
https://openprinting.github.io/cups/cups3.html
Apache License 2.0
27 stars 15 forks source link

Update dest.c to free memory free(data.devices); #70

Closed chandrakant2023 closed 7 months ago

chandrakant2023 commented 8 months ago

There is memory leak by cupsArrayNew3(..) as its return pointer to allocated memory which we need to free while return like free(data.devices);

chandrakant2023 commented 8 months ago

You don't free CUPS arrays, you cupsArrayDelete them...

in cupsArrayDelete "devices" not been free as this device only get allocated in cups_enum_dests(..) when there is

if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)

so, we may have to free it in cups_enum_dests(..) when there is any above condition is satisfied

Any thought ?

michaelrsweet commented 8 months ago

@chandrakant2023 If "devices" is not NULL, then a cups_array_t object has been allocated. I am OK with the goals of your PR, but you need to use the cupsArrayDelete function to free the memory and not the free function.

chandrakant2023 commented 8 months ago

@chandrakant2023 If "devices" is not NULL, then a cups_array_t object has been allocated. I am OK with the goals of your PR, but you need to use the cupsArrayDelete function to free the memory and not the free function.

Thank you for this, have used cupsArrayDelete() instead free() now for data.devices

michaelrsweet commented 7 months ago

Oh, and I just noticed this is a pull request against the wrong project - this might only apply to 2.4.x as 2.5 and 3.0 use a new CUPS DNS-SD API... Please re-file against the CUPS project.

chandrakant2023 commented 7 months ago

Oh, and I just noticed this is a pull request against the wrong project - this might only apply to 2.4.x as 2.5 and 3.0 use a new CUPS DNS-SD API... Please re-file against the CUPS project.

Hi, I checked the project you mentioned, However the code base I have issue on Rocky is pointing to this code base only and not 2.4.x or 3.0

This branch code base only has this memory leak issue which I am addressing in my code changes, please reconsider

michaelrsweet commented 7 months ago

@chandrakant2023 The libcups project is ONLY for shipping the CUPS Library v3 and later. Any version of CUPS prior to 3.0 is provided via the CUPS project and that is the only place you can get that code. Any legacy code/branches for prior CUPS releases is entirely accidental and an artifact of preserving the git history from the original project.

chandrakant2023 commented 6 months ago

@chandrakant2023 The libcups project is ONLY for shipping the CUPS Library v3 and later. Any version of CUPS prior to 3.0 is provided via the CUPS project and that is the only place you can get that code. Any legacy code/branches for prior CUPS releases is entirely accidental and an artifact of preserving the git history from the original project.

Thank you for this information.