Skip to content

Commit

Permalink
samples: Add simple sample which generate memory leak
Browse files Browse the repository at this point in the history
heaptrace report nothing on samples/sample.c test program
Add simple test program to check whether it detect memory allocation normally

Signed-off-by: Bojun Seo <[email protected]>
  • Loading branch information
Bojun-Seo authored and honggyukim committed Feb 23, 2023
1 parent 703b2ea commit 475f054
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion samples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif
CFLAGS := -rdynamic -funwind-tables
CXXFLAGS := $(CFLAGS)

SRCS := sample.c factorial.c
SRCS := factorial.c sample.c sample_leak.c
BINS := $(patsubst %.c,%.out,$(SRCS))

all: $(BINS)
Expand Down
18 changes: 18 additions & 0 deletions samples/sample_leak.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* Copyright (c) 2022 LG Electronics Inc. */
/* SPDX-License-Identifier: GPL-2.0 */
#include <stdlib.h>

int main(void)
{
int *p;

p = (int*)malloc(4);
//free(p);

p = (int*)calloc(4, 10);

p = (int*)realloc(p, 1000000);
free(p);

return 0;
}

0 comments on commit 475f054

Please sign in to comment.