Skip to content

Commit

Permalink
Avoid memory leaks
Browse files Browse the repository at this point in the history
The CFBundleName variable is assigned to 0-N driverTracker structures
and when they are freed, its leaked.

Signed-off-by: Jakub Jelen <[email protected]>
  • Loading branch information
Jakuje authored and LudovicRousseau committed May 22, 2024
1 parent 400f0cd commit 63a9371
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hotplug_libudev.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static LONG HPReadBundleValues(const char * hpDirPath)
if (rv)
CFBundleName = NULL;
else
CFBundleName = strdup(list_get_at(values, 0));
CFBundleName = list_get_at(values, 0);

/* while we find a nth ifdVendorID in Info.plist */
for (alias=0; alias<list_size(manuIDs); alias++)
Expand All @@ -210,7 +210,7 @@ static LONG HPReadBundleValues(const char * hpDirPath)
/* constant entries for a same driver */
driverTracker[listCount].bundleName = strdup(currFP->d_name);
driverTracker[listCount].libraryPath = strdup(fullLibPath);
driverTracker[listCount].CFBundleName = CFBundleName;
driverTracker[listCount].CFBundleName = CFBundleName ? strdup(CFBundleName) : NULL;

#ifdef DEBUG_HOTPLUG
Log2(PCSC_LOG_INFO, "Found driver for: %s",
Expand Down Expand Up @@ -696,6 +696,7 @@ LONG HPStopHotPluggables(void)
free(driverTracker[i].bundleName);
free(driverTracker[i].libraryPath);
free(driverTracker[i].readerName);
free(driverTracker[i].CFBundleName);
}
free(driverTracker);

Expand Down

0 comments on commit 63a9371

Please sign in to comment.