Code Review
/
src
/
libafb-helpers.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
| inline |
side by side
(parent:
95aaa4b
)
wrap-json: Fix bug decoding empty base64
author
jobol
<jose.bollo@iot.bzh>
Mon, 14 May 2018 09:19:34 +0000
(11:19 +0200)
committer
Romain Forlot
<romain.forlot@iot.bzh>
Thu, 13 Dec 2018 13:12:02 +0000
(14:12 +0100)
The function 'decode_base64' was buggy because
it freed 2 times the pointer 'result'.
This came from the fact realloc frees the
pointer and return NULL when the size if 0.
Signed-off-by: jobol <jose.bollo@iot.bzh>
wrap-json.c
patch
|
blob
|
history
diff --git
a/wrap-json.c
b/wrap-json.c
index
6c4da7b
..
11fdd8c
100644
(file)
--- a/
wrap-json.c
+++ b/
wrap-json.c
@@
-241,7
+241,7
@@
static int decode_base64(
/* terminate */
*decoded = realloc(result, out);
- if (*decoded == NULL) {
+ if (
out &&
*decoded == NULL) {
free(result);
return wrap_json_error_out_of_memory;
}
@@
-1134,6
+1134,7
@@
int main()
U("\"Pz8_Pz8_P2hlbGxvPj4-Pj4-Pg\"", "y", &xy[0], &xz[0]);
U("{\"foo\":\"Pz8_Pz8_P2hlbGxvPj4-Pj4-Pg\"}", "{s?y}", "foo", &xy[0], &xz[0]);
+ U("{\"foo\":\"\"}", "{s?y}", "foo", &xy[0], &xz[0]);
U("{}", "{s?y}", "foo", &xy[0], &xz[0]);
return 0;
}