carl douglas avatar carl douglas committed 000c45f

Prevent fetches when there is an error with the query.

Comments (0)

Files changed (1)

     (cond ((equal? '() parameters) (mysql-c-query conn query))
           (else (mysql-c-query conn (escape-placeholder-params conn query parameters)))))
   (define (fetch-c)(let ((row (mysql-c-fetch-row result-c)))
-                      (if (> (length row) 0) row #f)))
+                      (if (and row (> (length row) 0)) 
+                          row 
+                          #f)))
   (set-finalizer! result-c (lambda(x) (mysql-c-free-result result-c)))
-  fetch-c)
+  (if result-c 
+      fetch-c 
+      (lambda()#f)))
 
 (define (dispatch-proc conn proc . parameters)
   (proc conn parameters))
   dst = (char *)calloc(len1, sizeof(char));
   if (dst == NULL) {
     fprintf(stderr, "out of memory\n");
-    return(C_SCHEME_FALSE);
+    return(NULL);
   }
   len2 = mysql_real_escape_string(conn, dst, str, strlen(str));
   return(dst);
 (define mysql-c-fetch-row
   (foreign-lambda* c-string-list* ((c-pointer result))
 #<<END
-  int num_fields = mysql_num_fields(result);
-  int index = num_fields;
-  MYSQL_ROW row;
-  char **fields;
+  int num_fields = 0;
+  int index = 0;
+  MYSQL_ROW row = NULL;
+  char **fields = NULL;
+  if (result == NULL) {
+    return(NULL);
+  }
+  num_fields = mysql_num_fields(result);
+  index = num_fields;
   row = mysql_fetch_row(result);
   fields = (char **)calloc(num_fields + 1, sizeof(char *));
   if (fields == NULL) {
     fprintf(stderr, "out of memory\n");
-    return(C_SCHEME_FALSE);
+    return(NULL);
   }
   for (;row && index--;) {
     if (row[index] == NULL) 
   }
 
   if (rc != 0) {
-    C_return(NULL); /*C_return(C_SCHEME_FALSE);*/
+    return(NULL); /*C_return(C_SCHEME_FALSE);*/
   }
 
   result = mysql_store_result(conn);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.