Return value is changing...

int SelectSketchTable(String where, char *rows[]){
  String INSERT_ESP12E_SELECT_SQL = "SELECT * FROM SKETCHS WHERE name='" + where + ".bin'";
  dbg_printf("%s\n", INSERT_ESP12E_SELECT_SQL.c_str());
  MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
  Connect_to_MySQL();
  cur_mem->execute(INSERT_ESP12E_SELECT_SQL.c_str());
  column_names *columns = cur_mem->get_columns();
  for (int f = 0; f < columns->num_fields; f++) {
    Serial.print(columns->fields[f]->name);
    if (f < columns->num_fields - 1) {
      Serial.print(", ");
    }
  }
  dbg_printf("\n");
  row_values *row;
  int i = 0;
  do {
    row = cur_mem->get_next_row();
    if (row != nullptr) {
      for (int f = 0; f < columns->num_fields; f++) {
        //Serial.print(row->values[f]);
        rows[i] = row->values[f];
        Serial.print(rows[i]);
        i++;
        if (f < columns->num_fields - 1) {
          Serial.print(", ");
        }
      }
      Serial.println();
    }
  } while (row != nullptr);
  cur_mem->close();
  delete cur_mem;
  Disconnect_to_MySQL();
  dbg_printf("select end\n");
  return i;
}
ESP_INFO esp_info;
char *Rows[5];
memset(Rows,0,sizeof(char)*5);
int count = SelectSketchTable(esp_info.sketch_name, Rows);
dbg_printf("SelectSketchTable succeeded.\n");
for(int i = 0; i < count; i++)
{
  dbg_printf("%d -> %s\n", i, Rows[i]);
}

Results:

SELECT * FROM SKETCHS WHERE name='firmware.bin'
Connecting to MySql.
name, path, md5
firmware.bin, /var/www/html/firmware/ESP-12E/fw.bin, b0f36f5ad0affe3b4336fcaa80ac75c6
select end
SelectSketchTable succeeded.
0 -> 
1 -> '/www/html/firmware/ESP-12E/fw.bin
2 -> �

I can't get values of Rows variable correctly. Values are correct in the function, but they change when they return to the called position. What could be the reason for this.

      for (int f = 0; f < columns->num_fields; f++) {
        //Serial.print(row->values[f]);
        rows[i] = row->values[f];
        Serial.print(rows[i]);
        i++;
        if (f < columns->num_fields - 1) {
          Serial.print(", ");
        }
      }

You've made rows[ i ] point to some memory. That memory is NOT memory you own. That memory goes out of scope when the function ends.

You need to COPY the data pointed to, not point to it. strdup() would be useful, but you must free the copy when you are done with it.