comparison src/evalvars.c @ 20326:74002d42dda0 v8.2.0718

patch 8.2.0718: gcc warning for returning pointer to local variable Commit: https://github.com/vim/vim/commit/7d3664df9008bd5f39f8a2555843d1b269946e4d Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 9 13:06:24 2020 +0200 patch 8.2.0718: gcc warning for returning pointer to local variable Problem: Gcc warning for returning pointer to local variable. (John Marriott) Solution: Return another pointer.
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 May 2020 13:15:03 +0200
parents 2135b4641680
children 7587d892c00c
comparison
equal deleted inserted replaced
20325:c3bf737ec527 20326:74002d42dda0
2508 2508
2509 if (ht == NULL) 2509 if (ht == NULL)
2510 return NULL; 2510 return NULL;
2511 if (len < sizeof(buffer) - 1) 2511 if (len < sizeof(buffer) - 1)
2512 { 2512 {
2513 // avoid an alloc/free for short names
2513 vim_strncpy(buffer, name, len); 2514 vim_strncpy(buffer, name, len);
2514 p = buffer; 2515 p = buffer;
2515 } 2516 }
2516 else 2517 else
2517 { 2518 {
2527 if (res == NULL && find_imported(p, 0, NULL) != NULL) 2528 if (res == NULL && find_imported(p, 0, NULL) != NULL)
2528 res = p; 2529 res = p;
2529 2530
2530 if (p != buffer) 2531 if (p != buffer)
2531 vim_free(p); 2532 vim_free(p);
2532 return res; 2533 // Don't return "buffer", gcc complains.
2534 return res == NULL ? NULL : IObuff;
2533 } 2535 }
2534 2536
2535 /* 2537 /*
2536 * Find the hashtab used for a variable name. 2538 * Find the hashtab used for a variable name.
2537 * Return NULL if the name is not valid. 2539 * Return NULL if the name is not valid.