aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/github_commits.c4
-rw-r--r--doc/tutorial.rst5
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/github_commits.c b/doc/github_commits.c
index dde1be5..7b22e6a 100644
--- a/doc/github_commits.c
+++ b/doc/github_commits.c
@@ -128,6 +128,7 @@ int main(int argc, char *argv[])
if(!json_is_array(root))
{
fprintf(stderr, "error: root is not an array\n");
+ json_decref(root);
return 1;
}
@@ -140,6 +141,7 @@ int main(int argc, char *argv[])
if(!json_is_object(data))
{
fprintf(stderr, "error: commit data %d is not an object\n", i + 1);
+ json_decref(root);
return 1;
}
@@ -154,6 +156,7 @@ int main(int argc, char *argv[])
if(!json_is_object(commit))
{
fprintf(stderr, "error: commit %d: commit is not an object\n", i + 1);
+ json_decref(root);
return 1;
}
@@ -161,6 +164,7 @@ int main(int argc, char *argv[])
if(!json_is_string(message))
{
fprintf(stderr, "error: commit %d: message is not a string\n", i + 1);
+ json_decref(root);
return 1;
}
diff --git a/doc/tutorial.rst b/doc/tutorial.rst
index 79bd3b5..c2df081 100644
--- a/doc/tutorial.rst
+++ b/doc/tutorial.rst
@@ -178,6 +178,7 @@ We check that the returned value really is an array::
if(!json_is_array(root))
{
fprintf(stderr, "error: root is not an array\n");
+ json_decref(root);
return 1;
}
@@ -192,6 +193,7 @@ Then we proceed to loop over all the commits in the array::
if(!json_is_object(data))
{
fprintf(stderr, "error: commit data %d is not an object\n", i + 1);
+ json_decref(root);
return 1;
}
...
@@ -209,6 +211,7 @@ object. We also do proper type checks::
if(!json_is_string(sha))
{
fprintf(stderr, "error: commit %d: sha is not a string\n", i + 1);
+ json_decref(root);
return 1;
}
@@ -216,6 +219,7 @@ object. We also do proper type checks::
if(!json_is_object(commit))
{
fprintf(stderr, "error: commit %d: commit is not an object\n", i + 1);
+ json_decref(root);
return 1;
}
@@ -223,6 +227,7 @@ object. We also do proper type checks::
if(!json_is_string(message))
{
fprintf(stderr, "error: commit %d: message is not a string\n", i + 1);
+ json_decref(root);
return 1;
}
...