Update sdb fixing some coverity warns

This commit is contained in:
pancake 2014-07-12 00:25:58 +02:00
parent 10dc0c6ef4
commit cac402ef63
2 changed files with 4 additions and 5 deletions

View File

@ -81,10 +81,11 @@ typedef struct {
static int foreach_list_cb(void *user, const char *k, const char *v) {
ForeachListUser *rlu = user;
char *line, *root = rlu->root;
char *line, *root;
int rlen, klen, vlen;
ut8 *v2 = NULL;
if (!rlu) return 0;
root = rlu->root;
klen = strlen (k);
if (rlu->encode) {
v2 = sdb_decode (v, NULL);

View File

@ -220,9 +220,8 @@ SDB_API const char *sdb_type(const char *k) {
SDB_API int sdb_isjson (const char *k) {
int level = 0;
int quotes = 0;
if (*k!='{' && *k != '[')
if (!k || (*k!='{' && *k != '['))
return 0;
if (k)
for (; *k; k++) {
if (quotes) {
if (*k == '"')
@ -231,8 +230,7 @@ SDB_API int sdb_isjson (const char *k) {
}
switch (*k) {
case '"':
if (quotes) quotes = 0;
else quotes = 1;
quotes = 1;
break;
case '[':
case '{':