diff --git a/src/post_modules/SQLite/sqlite.cmod b/src/post_modules/SQLite/sqlite.cmod index d682c43eca353652d7ec477f3b35b9396fa941ee..2df0c52919b026b3823253fdb9d9309e65766123 100644 --- a/src/post_modules/SQLite/sqlite.cmod +++ b/src/post_modules/SQLite/sqlite.cmod @@ -229,6 +229,16 @@ PIKECLASS ResObj */ PIKEFUN array(mapping(string:mixed)) fetch_fields() { int i,t; + if (!sqlite3_column_name(THIS->stmt, 0)) { + /* Documented to happen on malloc() failure, + * but can apparently happen in other cases too. + * The common case seems to be when called after + * the last row has been fetched. + * Cf #10035. + */ + push_int(0); + return; + } for(i=0; i<THIS->columns; i++) { push_constant_text("name"); push_text(sqlite3_column_name(THIS->stmt, i));