diff options
author | Safey A.Halim <safey.allah@gmail.com> | 2011-02-25 10:13:28 +0000 |
---|---|---|
committer | Safey A.Halim <safey.allah@gmail.com> | 2011-02-25 10:13:28 +0000 |
commit | 5232542d7ed273d800445ac8ebf7774c28513865 (patch) | |
tree | 79c24df5b4ee0cda0a66e050ca93644910e7b61a /src/monkey | |
parent | 134da5387304c6b1963bba21f14241402cc085a2 (diff) | |
download | gnunet-5232542d7ed273d800445ac8ebf7774c28513865.tar.gz gnunet-5232542d7ed273d800445ac8ebf7774c28513865.zip |
codesonar problems fixed
Diffstat (limited to 'src/monkey')
-rw-r--r-- | src/monkey/gdbmi_parse.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/monkey/gdbmi_parse.c b/src/monkey/gdbmi_parse.c index e3767c418..678276ba3 100644 --- a/src/monkey/gdbmi_parse.c +++ b/src/monkey/gdbmi_parse.c | |||
@@ -50,15 +50,12 @@ int mi_get_cstring_r(mi_results *r, const char *str, const char **end) | |||
50 | /* Meassure. */ | 50 | /* Meassure. */ |
51 | for (s=str, len=0; *s && !EndOfStr(s); s++) | 51 | for (s=str, len=0; *s && !EndOfStr(s); s++) |
52 | { | 52 | { |
53 | if (!*s) { | ||
54 | mi_error = MI_PARSER; | ||
55 | return 0; | ||
56 | } | ||
53 | if (*s=='\\') | 57 | if (*s=='\\') |
54 | { | 58 | s++; |
55 | if (!*s) | ||
56 | { | ||
57 | mi_error=MI_PARSER; | ||
58 | return 0; | ||
59 | } | ||
60 | s++; | ||
61 | } | ||
62 | len++; | 59 | len++; |
63 | } | 60 | } |
64 | /* Copy. */ | 61 | /* Copy. */ |
@@ -117,8 +114,10 @@ char *mi_get_var_name(const char *str, const char **end) | |||
117 | l=s-str; | 114 | l=s-str; |
118 | r=mi_malloc(l+1); | 115 | r=mi_malloc(l+1); |
119 | /* Copy. */ | 116 | /* Copy. */ |
120 | memcpy(r,str,l); | 117 | if (NULL != r) { |
121 | r[l]=0; | 118 | memcpy(r,str,l); |
119 | r[l]=0; | ||
120 | } | ||
122 | if (end) | 121 | if (end) |
123 | *end=s+1; | 122 | *end=s+1; |
124 | return r; | 123 | return r; |
@@ -1086,16 +1085,16 @@ int mi_res_changelist(mi_h *h, mi_gvar_chg **changed) | |||
1086 | n->name=r->v.cstr; | 1085 | n->name=r->v.cstr; |
1087 | r->v.cstr=NULL; | 1086 | r->v.cstr=NULL; |
1088 | } | 1087 | } |
1089 | else if (strcmp(r->var,"in_scope")==0) | 1088 | else if ((NULL != n) && (strcmp(r->var,"in_scope")==0)) |
1090 | { | 1089 | { |
1091 | n->in_scope=strcmp(r->v.cstr,"true")==0; | 1090 | n->in_scope=strcmp(r->v.cstr,"true")==0; |
1092 | } | 1091 | } |
1093 | else if (strcmp(r->var,"new_type")==0) | 1092 | else if ((NULL != n) && (strcmp(r->var,"new_type")==0)) |
1094 | { | 1093 | { |
1095 | n->new_type=r->v.cstr; | 1094 | n->new_type=r->v.cstr; |
1096 | r->v.cstr=NULL; | 1095 | r->v.cstr=NULL; |
1097 | } | 1096 | } |
1098 | else if (strcmp(r->var,"new_num_children")==0) | 1097 | else if ((NULL != n) && (strcmp(r->var,"new_num_children")==0)) |
1099 | { | 1098 | { |
1100 | n->new_num_children=atoi(r->v.cstr); | 1099 | n->new_num_children=atoi(r->v.cstr); |
1101 | } | 1100 | } |
@@ -1133,7 +1132,7 @@ int mi_get_children(mi_results *ch, mi_gvar *v) | |||
1133 | return 0; | 1132 | return 0; |
1134 | if (!v->child) | 1133 | if (!v->child) |
1135 | v->child=aux; | 1134 | v->child=aux; |
1136 | else | 1135 | else if (NULL != cur) |
1137 | cur->next=aux; | 1136 | cur->next=aux; |
1138 | cur=aux; | 1137 | cur=aux; |
1139 | cur->parent=v; | 1138 | cur->parent=v; |
@@ -1738,9 +1737,12 @@ mi_chg_reg *mi_parse_list_regs(mi_results *r, int *how_many) | |||
1738 | cur=cur->next=mi_alloc_chg_reg(); | 1737 | cur=cur->next=mi_alloc_chg_reg(); |
1739 | else | 1738 | else |
1740 | first=cur=mi_alloc_chg_reg(); | 1739 | first=cur=mi_alloc_chg_reg(); |
1741 | cur->name=c->v.cstr; | 1740 | |
1742 | cur->reg=cregs++; | 1741 | if (NULL != cur) { |
1743 | c->v.cstr=NULL; | 1742 | cur->name=c->v.cstr; |
1743 | cur->reg=cregs++; | ||
1744 | c->v.cstr=NULL; | ||
1745 | } | ||
1744 | } | 1746 | } |
1745 | c=c->next; | 1747 | c=c->next; |
1746 | } | 1748 | } |
@@ -1891,12 +1893,14 @@ mi_chg_reg *mi_parse_reg_values_l(mi_results *r, int *how_many) | |||
1891 | { | 1893 | { |
1892 | if (strcmp(c->var,"number")==0) | 1894 | if (strcmp(c->var,"number")==0) |
1893 | { | 1895 | { |
1894 | cur->reg=atoi(c->v.cstr); | 1896 | if (NULL != cur) |
1897 | cur->reg=atoi(c->v.cstr); | ||
1895 | (*how_many)++; | 1898 | (*how_many)++; |
1896 | } | 1899 | } |
1897 | else if (strcmp(c->var,"value")==0) | 1900 | else if (strcmp(c->var,"value")==0) |
1898 | { | 1901 | { |
1899 | cur->val=c->v.cstr; | 1902 | if (NULL != cur) |
1903 | cur->val=c->v.cstr; | ||
1900 | c->v.cstr=NULL; | 1904 | c->v.cstr=NULL; |
1901 | } | 1905 | } |
1902 | } | 1906 | } |