xbps_get_pkg_{name,version}: check for strrchr() returning NULL.

--HG--
extra : convert_revision : 4d63c1834f7b3c3b1a0395a7434095e9fc341885
This commit is contained in:
Juan RP 2009-02-17 23:28:40 +01:00
parent 952a8f9266
commit 6f8647f5c8

View file

@ -117,7 +117,9 @@ xbps_get_pkg_version(const char *pkg)
/* Get the required version */
tmp = strrchr(pkg, '-');
assert(tmp != NULL);
if (tmp == NULL)
return NULL;
return tmp + 1; /* skip first '-' */
}
@ -132,7 +134,9 @@ xbps_get_pkg_name(const char *pkg)
/* Get package name */
tmp = strrchr(pkg, '-');
assert(tmp != NULL);
if (tmp == NULL)
return NULL;
len = strlen(pkg) - strlen(tmp) + 1;
pkgname = malloc(len);