lib/srdb1 Prevent crash in case of incorrect parameter
authorMarius Zbihlei <marius.zbihlei@1and1.ro>
Fri, 14 Jan 2011 15:04:09 +0000 (17:04 +0200)
committerMarius Zbihlei <marius.zbihlei@1and1.ro>
Fri, 14 Jan 2011 15:04:09 +0000 (17:04 +0200)
Reported by clang.

lib/srdb1/db_id.c

index 7a8b5d7..2761c65 100644 (file)
@@ -207,12 +207,14 @@ static int parse_db_url(struct db_id* id, const str* url)
        return 0;
 
  err:
+       if (!id) goto end;
        if (id->scheme) pkg_free(id->scheme);
        if (id->username) pkg_free(id->username);
        if (id->password) pkg_free(id->password);
        if (id->host) pkg_free(id->host);
        if (id->database) pkg_free(id->database);
        if (prev_token) pkg_free(prev_token);
+ end:
        return -1;
 }