From 9a3246173ce1d855beebe83f44849e2aa0cf2e4a Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 10 Mar 2024 15:24:37 +0000 Subject: slbt_ar_get_archive_ctx(): store a private copy of the archive path. --- src/arbits/slbt_archive_ctx.c | 7 ++++++- src/internal/slibtool_driver_impl.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/arbits/slbt_archive_ctx.c b/src/arbits/slbt_archive_ctx.c index a110e97..a22c806 100644 --- a/src/arbits/slbt_archive_ctx.c +++ b/src/arbits/slbt_archive_ctx.c @@ -52,6 +52,7 @@ static int slbt_ar_free_archive_ctx_impl(struct slbt_archive_ctx_impl * ctx, int if (ctx) { slbt_ar_free_archive_meta(ctx->meta); slbt_unmap_raw_archive(&ctx->map); + free(ctx->pathbuf); free(ctx); } @@ -84,8 +85,12 @@ int slbt_ar_get_archive_ctx( return slbt_ar_free_archive_ctx_impl(ctx, SLBT_NESTED_ERROR(dctx)); + if (!(ctx->pathbuf = strdup(path))) + return slbt_ar_free_archive_ctx_impl(ctx, + SLBT_NESTED_ERROR(dctx)); + ctx->dctx = dctx; - ctx->path = path; + ctx->path = ctx->pathbuf; ctx->actx.path = &ctx->path; ctx->actx.map = &ctx->map; ctx->actx.meta = ctx->meta; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 600b02f..e6e21ea 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -196,6 +196,7 @@ struct slbt_exec_ctx_impl { struct slbt_archive_ctx_impl { const struct slbt_driver_ctx * dctx; const char * path; + char * pathbuf; struct slbt_raw_archive map; struct slbt_archive_meta * meta; struct slbt_archive_ctx actx; -- cgit v1.2.3