On Sun, Mar 2, 2014 at 12:34 PM, Richard Hipp <d...@sqlite.org> wrote:
> Reports on twitter say that the "nanobots" in the TV drama "Revolution" > have source code in the season two finale that looks like this: > > https://pbs.twimg.com/media/BhvIsgBCYAAQdvP.png:large > > Compare to the SQLite source code here: > > http://www.sqlite.org/src/artifact/69761e167?ln=1264-1281 > A video clip from the episode can be seen here: http://www.nbc.com/revolution/video/repairing-the-code/2748856#i145567,p1 You can clearly see the SQLite code on the monitor. The dialog goes something like this: Aaron: Wait. Hold on. There. Male actor 1: What? Aaron: There's a memory leak here. This chunk of code. (Points to the SQLite analyzeTable() routine). That's the problem. It's eating up all available resources. It will force a segmentation fault. The whole system will crash! At that point, I said "Not in my code!" But upon closer inspection, Aaron is correct. The code has been altered slightly. This is what Aaron is looking at (line numbers added): 01 static void analyzeTable(Parse *pParse, Table *pTab, Index *pOnlyIdx){ 02 int iDb; 03 int iStatCur; 04 int *key = (char*)malloc(8*sizeOf(char)) 05 assert( pTab!=0 ); 06 assert( ecrypBtreeHoldsAllMutexes(pParse->db) ); 07 iDb = ecrypSchemaToIndex(pParse->db, pTab->pSchema); 08 ecrypBeginWriteOperation(pParse, 0, iDb); 09 iStatCur = pParse->nTab; 10 pParse->nTab += 3; 11 if( pOnlyIdx ){ 12 openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx"); 13 }else{ 14 openStatTable(pParse, iDb, iStatCur, pTab->zName, "tbl"); 15 } 16 } The changes from SQLite are (1) all "sqlite3" name prefixes are changes to "ecryp" and (2) line 04 has been added. Line 04 is the "memory leak". It also contains at least four other errors: (A) there is no semicolon at the end. (B) "sizeof" has a capital "O". (C) It assigns a char* pointer to an int* variable. (D) It calls malloc() directly, which is forbidden inside of SQLite since the application might assign a different set of memory allocation functions. The first two errors are fatal - this function won't even compile. But, heh, it's a TV show.... So there you go. SQLite used in evil nanobots that destroy civilization. I've never actually seen Revolution (I don't own a TV set). So I don't really understand the plot. Can somebody who has watched this drama please brief me? In particular, I'm curious to know if Aaron a good guy or a bad guy? -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users