Skip to content

Commit

Permalink
Fix leaks from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo- committed May 22, 2024
1 parent fc7dad1 commit 09ad2ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions devel/libyajl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ GH_ACCOUNT = lloyd
GH_PROJECT = yajl
GH_TAGNAME = 2.1.0
PKGNAME = lib${DISTNAME}
REVISION = 0

CATEGORIES = devel

Expand Down
31 changes: 31 additions & 0 deletions devel/libyajl/patches/patch-src_yajl_tree_c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Plug leaks. From upstream

https://github.com/lloyd/yajl/issues/250#issuecomment-1628695214
https://github.com/likema/yajl/commit/31531a6e6b5641398237ce15b7e62da02d975fc6

Index: src/yajl_tree.c
--- src/yajl_tree.c.orig
+++ src/yajl_tree.c
@@ -144,6 +144,7 @@ static yajl_val context_pop(context_t *ctx)

v = stack->value;

+ free (stack->key);
free (stack);

return (v);
@@ -444,7 +445,14 @@ yajl_val yajl_tree_parse (const char *input,
snprintf(error_buffer, error_buffer_size, "%s", internal_err_str);
YA_FREE(&(handle->alloc), internal_err_str);
}
+ while(ctx.stack != NULL) {
+ yajl_val v = context_pop(&ctx);
+ yajl_tree_free(v);
+ }
yajl_free (handle);
+ //If the requested memory is not released in time, it will cause memory leakage
+ if(ctx.root)
+ yajl_tree_free(ctx.root);
return NULL;
}

2 changes: 1 addition & 1 deletion devel/libyajl/pkg/PLIST
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ include/yajl/yajl_parse.h
include/yajl/yajl_tree.h
include/yajl/yajl_version.h
@lib lib/libyajl.so.${LIByajl_VERSION}
lib/libyajl_s.a
@static-lib lib/libyajl_s.a
share/pkgconfig/yajl.pc

0 comments on commit 09ad2ce

Please sign in to comment.