Is this code correct?

Hi, I have a question about this function, I'm not sure if it's correct it works but when I add this function to loop sometimes i get this error:

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x40056722 PS : 0x00060c30 A0 : 0x8005682e A1 : 0x3ffb1ea0
A2 : 0x3ffb80c0 A3 : 0x800d1da9 A4 : 0x00000000 A5 : 0x0000000a
A6 : 0x800d1da9 A7 : 0x00000008 A8 : 0x8000be99 A9 : 0x3ffb1e90
A10 : 0x3ffb80c0 A11 : 0x00060c23 A12 : 0x00060c20 A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000018 EXCCAUSE: 0x0000001c
EXCVADDR: 0x800d1da9 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x00000000

ELF file SHA256: 0000000000000000

Backtrace: 0x40056722:0x3ffb1ea0 0x4005682b:0x3ffb1ed0 0x400566cd:0x3ffb1ef0 0x400d1e5d:0x3ffb1f10 0x400d1ee7:0x3ffb1f90 0x400d9b75:0x3ffb1fb0 0x4008a4e2:0x3ffb1fd0

void led()
{
  
  String mystring;
  




  mystring = Firebase.getString("LED_R");
  char nowy[30];
  mystring.toCharArray(nowy,30);

  char *strings[6]; 
  char *ptr = NULL;

int led_r;
int led_g;
int led_b;

  byte index = 0;
   ptr = strtok(nowy, ",");  // delimiter
   while (ptr != NULL)
   {
      strings[index] = ptr;
      index++;
      ptr = strtok(NULL, ",");
   }
 
   led_r = atoi(strings[0]); 
   led_g = atoi(strings[1]);
   led_b = atoi(strings[2]);

 
 


for (int i=0; i<num_led; i++){
    leds[i] = CRGB(led_r, led_g, led_b );
    
    FastLED.show();
   
  }
  
}

Not sure if it is (solving) the problem but I would add a boundary check to the below snippet so you can not write to strings[6_or_higher].

  while (ptr != NULL)
  {
    strings[index] = ptr;
    index++;
    ptr = strtok(NULL, ",");
  }

My guess is that the string you receive doesn't have as many commas as you expect. That would leave some of your pointers uninitialized and that would cause a crash when you go to convert them to integer values.

Try pointing them to a default string. Then, if they don't get initialized they are at least pointing to memory that you own.

  char def[] = "0";
  char *strings[6] = {def, def, def, def, def, def}; 

What do your Serial debug prints tell you (hint)?

Run the ESP Exception Decoder. Post the results.

Post your COMPLETE code. My guess is either that you're dereferencing a NULL pointer or blowing up the stack allocation for the FreeRTOS task you're running. No way to tell without complete information.