Commit Diff


commit - c1f7b2cc26e859c6e29009c1ade477891952159d
commit + 0b0bdb50885c888de89592492c7198061933689b
blob - edaaafa80021cd6627de6cf130ea941d0e55ed69
blob + edf31954b8d7c26ca7e0061a6bcb525a11a4c851
--- sqlite3.c
+++ sqlite3.c
@@ -217,7 +217,7 @@ sq3simple(char *sql, StringList *words)
 	sqlite3		*db = NULL;
 	sqlite3_stmt	*stmt;
 	char		*result, *new = NULL;
-	int		rv, len, tlen = 0;
+	int		rv, tlen = 0;
 
 	if (sqlite3_open(SQ3DBFILE, &db)) {
 		printf("%% database file open failed: %s\n",
@@ -235,13 +235,13 @@ sq3simple(char *sql, StringList *words)
 
 	while ((rv = sqlite3_step(stmt)) == SQLITE_ROW) {
 		result = (char *)sqlite3_column_text(stmt, 0);
-		len = strlen(result) + 1;
-		if ((new = malloc(len)) == NULL) {
-			printf("%% sq3simple: malloc failed\n");
+		new = strdup(result);
+		if (new == NULL) {
+			printf("%% sq3simple: strdup failed: %s\n",
+			    strerror(errno));
 			break;
 		}
-		tlen += len;
-		strlcpy(new, result, len);
+		tlen += strlen(new) + 1;
 		sl_add(words, new);
 	}