Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:40:40+00:00 2026-06-04T22:40:40+00:00

The following app crashes with nullpointer. I am wondering whats wrong… #include stdio.h #include

  • 0

The following app crashes with nullpointer. I am wondering whats wrong…

#include "stdio.h"
#include "string.h"

char* getFileData(char* fileName);
bool createShader( int shaderType, const char* shader, const char* shaderFile ) ;
void glShaderSource(int shader, int count, const char** string, const int* length);

int main(int argc, char* argv[])
{
    char* shader = getFileData("filea.csd");
    bool success = createShader(1, shader, "filea.csd");
    return 0;
}

char* getFileData(char* fileName) {
    if(!strcmp(fileName, "filea.csd"))
        return "this is the content of the file a\0";
    else if(!strcmp(fileName, "fileb.csd"))
        return "this is the content of the file b\0";
    else if(!strcmp(fileName, "filec.csd"))
        return "this is the content of the file c\0";
    else 
        return "";
}

bool createShader( int shaderType, const char* shader, const char* shaderFile ) 
{
    int shaderHandle = 122;

    glShaderSource( shaderHandle, 1, &shader, NULL ); ////This line is where it crashes.
    return true;
}

void glShaderSource(int shader, int count, const char** string, const int* length) {
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:40:42+00:00Added an answer on June 4, 2026 at 10:40 pm

    Since the Pointer is NULL, try passing the double pointer. Something of the form

    bool createShader( GLenum shaderType, const char** shader, const char* shaderFile )//<-- change 
    {
        GLuint shaderHandle = glCreateShader( shaderType );
    
        glShaderSource( shaderHandle, 1, shader, NULL ); //<--change
        glCompileShader( shaderHandle );
    
        int status = 0;
    
        glGetShaderiv( shaderHandle, GL_COMPILE_STATUS, &status );
    }
    
    void main () {
          char* shader = strdup(getFileData("filea.csd"));
          bool success = createShader(shaderType, &shader, "filea.csd"); //<--change
          delete shader;
          return success;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My iphone app crashes with the following error message: 2010-07-26 16:27:30.402 Nav[814:207] * -[UITextField
I got the following crash logs after my app crashes: 0 libobjc.A.dylib 0x000034f4 objc_msgSend
I have an iPhone app which uses iAd...The app crashes sometime with the following
I've written the following DB query. However, the app crashes when I access the
When I run the following Silverlight app, it gives me the error : AG_E_PARSER_BAD_PROPERTY_VALUE
I have follwing JSON: {mykey:[{name:Jak,interests:movies}]} and following opensocial app code: <script type=text/os-template require=mykey> <ul>
I have following flow of app : First screen is Login screen and if
I have a the following server side app.config for a WCF service: <system.serviceModel> <bindings>
I am creating a SMS app the following code is supposed to: check if
I have a PHP app running happily on the following system: web app: PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.