]> pd.if.org Git - zpackage/commitdiff
fixup
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 16 Dec 2018 16:24:03 +0000 (16:24 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 16 Dec 2018 16:24:03 +0000 (16:24 +0000)
lib/zpm.c

index 11ee22cc36f6768d161b3a334d401d61d52be1c6..3cc7632d76280dacb9e4be3957a1794415a7d4a5 100644 (file)
--- a/lib/zpm.c
+++ b/lib/zpm.c
@@ -307,11 +307,26 @@ int zpm_close(struct zpm *pkg) {
 
 static int zpm_sqlite_vercmp(void *not_used, int lena, const void *a,
                int lenb, const void *b) {
-       /* not sure what the ints are, possibly string lengths */
+       int rv;
+       char *bufa, *bufb;
+
        if (not_used != 0) fprintf(stderr, "sqlite vercmp not_used = %p\n",
                        not_used);
        if (lena == 0 && lenb > 0) return 1;
-       return zpm_vercmp(a, b);
+       if (lenb == 0 && lena > 0) return -1;
+
+       bufa = sqlite3_malloc(lena+1);
+       bufb = sqlite3_malloc(lenb+1);
+
+       strncpy(bufa, a, lena);
+       strncpy(bufb, b, lenb);
+       bufa[lena] = 0;
+       bufb[lenb] = 0;
+
+       rv = zpm_vercmp(bufa, bufb);
+       sqlite3_free(bufa);
+       sqlite3_free(bufb);
+       return rv;
 }
 
 int zpm_addvercmp(struct zpm *pkg) {