crda: don't memset ctx before releasing members
PATCH 1/1 crda: don't memset ctx before releasing members
reglib_free_regdb_ctx() is currently memsetting the passed context to all 0s and then attempts to unmap/release its members.
Obviouly this can't work, because after the memset() all ctx's members will not be useful anymore. Attempting to release them may actually lead to crashes. Even if no crash should happen, this operation will still result in memleaks.
Fix this issue by removing the memset() at all, thus leaving the members intact so that they can be properly released.
--- reglib.c | 1 - 1 file changed, 1 deletion(-)
reglib.c +0 -1
@@ -287,7 +287,6 @@ void reglib_free_regdb_ctx(const struct reglib_regdb_ctx *regdb_ctx) ctx = (struct reglib_regdb_ctx *) regdb_ctx; -memset (ctx,0 ,sizeof (struct reglib_regdb_ctx ));close (ctx->fd);munmap (ctx->db, ctx->real_dblen);free (ctx);
Signature · 1 line
2.27.0
Hi guys,
Quoted 8 lines · Antonio Quartulli
reglib_free_regdb_ctx()is currently memsetting the passed context to all 0s and then attempts to unmap/release its members.Obviouly this can't work, because after the
memset()all ctx's members will not be useful anymore. Attempting to release them may actually lead to crashes. Even if no crash should happen, this operation will still result in memleaks.
Quoted 5 lines
Fix this issue by removing the
memset()at all, thus leaving the members intact so that they can be properly released.Signed-off-by Kelvin Chui <[email protected]>Signed-off-by Antonio Quartulli <[email protected]>
Just checking if this patch is still of interest and if there is something I could do to get it merged?
Best Regards,
Signature · 1 line
Antonio Quartulli