Fix UB in cannotated_code (#17833)

This commit is contained in:
pancake 2020-12-06 18:09:29 +01:00 committed by GitHub
parent e2f4461d18
commit 2ca1ec63e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,7 @@ R_API void r_core_annotated_code_print_json(RAnnotatedCode *code) {
break;
case R_CODE_ANNOTATION_TYPE_SYNTAX_HIGHLIGHT:
pj_ks (pj, "type", "syntax_highlight");
type_str = NULL;
switch (annotation->syntax_highlight.type) {
case R_SYNTAX_HIGHLIGHT_TYPE_KEYWORD:
type_str = "keyword";
@ -77,7 +78,9 @@ R_API void r_core_annotated_code_print_json(RAnnotatedCode *code) {
type_str = "global_variable";
break;
}
pj_ks (pj, "syntax_highlight", type_str);
if (type_str) {
pj_ks (pj, "syntax_highlight", type_str);
}
break;
}
pj_end (pj);